string.Format("rspauth={0}",
public string rspauth(string Username, string Realm, string Password, string Nonce, string Cnonce,
string m_Authzid, string m_DigestUri, string Qop, string m_Nc)
{
// HEX( KD ( HEX(H(A1)),
// { nonce-value, ":" nc-value, ":",
// cnonce-value, ":", qop-value, ":", HEX(H(A2)) }))
//If authzid is specified, then A1 is
// A1 = { H( { username-value, ":", realm-value, ":", passwd } ),
// ":", nonce-value, ":", cnonce-value, ":", authzid-value }
//If authzid is not specified, then A1 is
// A1 = { H( { username-value, ":", realm-value, ":", passwd } ),
// ":", nonce-value, ":", cnonce-value }
// The server receives and validates the "digest-response". The server
//checks that the nonce-count is "00000001". If it supports subsequent
//authentication (see section 2.2), it saves the value of the nonce and
//the nonce-count. It sends a message formatted as follows:
// response-auth = "rspauth" "=" response-value
//where response-value is calculated as above, using the values sent in
//step two, except that if qop is "auth", then A2 is
// A2 = { ":", digest-uri-value }
//And if qop is "auth-int" or "auth-conf" then A2 is
// A2 = { ":", digest-uri-value, ":00000000000000000000000000000000" }
byte[] H1;
byte[] H2;
byte[] H3;
// byte[] temp;
string A1;
string A2;
string A3;
string p1;
string p2;
var sb = new StringBuilder();
sb.Append(Username);
sb.Append(":");
sb.Append(Realm);
sb.Append(":");
sb.Append(Password);
H1 = new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes(sb.ToString()));
sb.Remove(0, sb.Length);
sb.Append(":");
sb.Append(Nonce);
sb.Append(":");
sb.Append(Cnonce);
if (m_Authzid != null)
{
sb.Append(":");
sb.Append(m_Authzid);
}
A1 = sb.ToString();
byte[] bA1 = Encoding.ASCII.GetBytes(A1);
var bH1A1 = new byte[H1.Length + bA1.Length];
// Array.Copy(H1, bH1A1, H1.Length);
Array.Copy(H1, 0, bH1A1, 0, H1.Length);
Array.Copy(bA1, 0, bH1A1, H1.Length, bA1.Length);
H1 = new MD5CryptoServiceProvider().ComputeHash(bH1A1);
// Console.WriteLine(util.Hash.HexToString(H1));
sb.Remove(0, sb.Length);
sb.Append(":");
sb.Append(m_DigestUri);
//if (Qop.CompareTo("auth") != 0)
//{
// sb.Append(":00000000000000000000000000000000");
//}
A2 = sb.ToString();
//H2 = Encoding.ASCII.GetBytes(A2);
H2 = Encoding.UTF8.GetBytes(A2);
H2 = new MD5CryptoServiceProvider().ComputeHash(H2);
// create p1 and p2 as the hex representation of H1 and H2
p1 = Hash.HexToString(H1).ToLower();
p2 = Hash.HexToString(H2).ToLower();
sb.Remove(0, sb.Length);
sb.Append(p1);
sb.Append(":");
sb.Append(Nonce);
sb.Append(":");
sb.Append(m_Nc);
sb.Append(":");
sb.Append(Cnonce);
sb.Append(":");
sb.Append(Qop);
sb.Append(":");
sb.Append(p2);
A3 = sb.ToString();
H3 = new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes(A3));
var m_Response = Hash.HexToString(H3).ToLower();
return m_Response;
}
string.Format("rspauth={0}",的更多相关文章
- C#:String.Format数字格式化输出 {0:N2} {0:D2} {0:C2}等等
int a = 12345678; //格式为sring输出// Label1.Text = string.Format("asdfadsf{0}adsfasdf",a); / ...
- String.Format数字格式化输出 {0:N2} {0:D2} {0:C2
//格式为sring输出 // Label1.Text = string.Format("asdfadsf{0}adsfasdf",a); // Label2.Text = ...
- 【转】C# String.Format数字格式化输出各种转换{0:N2} {0:D2} {0:C2}...
; //格式为sring输出 // Label1.Text = string.Format("asdfadsf{0}adsfasdf",a); // Label2.Text = & ...
- C#:String.Format数字格式化输出 {0:N2} {0:D2} {0:C2}...
int a = 12345678; //格式为sring输出// Label1.Text = string.Format("asdfadsf{0}adsfasdf",a);// ...
- String.Format数字格式化输出 {0:N2} {0:D2} {0:C2} (转)
String.Format数字格式化输出 {:N2} {:D2} {:C2} (转) //格式为sring输出 // Label1.Text = string.Format("asdfads ...
- c#字符显示转换{0:d} string.Format()
这一篇实际和前几个月写的没什么本质上的区别.但是这篇更明确一点,学起来easy c#字符显示转换{0:d} C#:String.Format数字格式化输出 : int a = 12345678; // ...
- C# String.Format格式化json字符串中包含"{" "}"报错问题
json.Append(String.Format("{\"total\":{0},\"row\":{1}}", lineCount, st ...
- $是对string.Format的简化
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 如何在string.Format()方法中输出大括号
在string.Format参数中,大括号{}是有特殊意义的符号,但是如果我们希望最终的结果中包含大括号({}),那么我们需要怎么做呢?是”\{”吗?很遗憾,运行时,会给你一个Exception的!正 ...
随机推荐
- 169. Majority Element 出现次数超过n/2的元素
[抄题]: Given an array of size n, find the majority element. The majority element is the element that ...
- 测试URL
http://localhost:8080/dmonitor-webapi/monitor/vm/342?r=1410331220921&indexes=cpu&indexes=mem ...
- Runnable和Thread实现多线程的区别(含代码)
转载请注明出处:http://blog.csdn.net/ns_code/article/details/17161237 Java中实现多线程有两种方法:继承Thread类.实现Runnable接口 ...
- back propogation 的线代描述
参考资料: 算法部分: standfor, ufldl : http://ufldl.stanford.edu/wiki/index.php/UFLDL_Tutorial 一文弄懂BP:https: ...
- HDU 6097 Mindis (计算几何)
题意:给一个圆C和圆心O,P.Q是圆上或圆内到圆心距离相等的两个点,在圆上取一点D,求|PD| + |QD|的最小值 析:首先这个题是可以用三分过的,不过也太,.... 官方题解: 很不幸不总是中垂线 ...
- 编写高质量代码改善C#程序的157个建议——建议81:使用Parallel简化同步状态下Task的使用
建议81:使用Parallel简化同步状态下Task的使用 在命名空间System.Threading.Tasks中,有一个静态类Parallel简化了在同步状态下的Task的操作.Parallel主 ...
- 【前端布局】px与rpx的简述
本文只以移动设备为例说明. 注意:设计师以iphone6为标准出设计稿的话,1rpx=0.5px=1物理像素.Photoshop里面量出来的尺寸为物理像素点.所以可以直接使用标注尺寸数据. [像素Pi ...
- 6、Semantic-UI之动画按钮样式
6.1 动画按钮样式 在Semantic-UI中提供了三种动画样按钮式表,分别为: 左右移动 上下移动 淡入淡出 在实际开发中,很少使用这种动画按钮,根据实际情况使用,强制使用到页面中反而不太适合 ...
- airpods2代连接macbook失败
更新至最新系统(10.14.4),更新完毕,重启电脑再次连接即可. 参考连接: http://dq.tieba.com/p/6082366443
- Window-document-javascript
一个浏览器窗口有一个window对象,javascript属于window对象,html为document对象,属于window,body为document对象,只有设置body对象高度为100%,其 ...