|
|
导航: |
论坛 -> 移动应用开发
斑竹:flyers,iamdream |
|
作者: |
|
2011/6/24 11:41:07 |
标题: |
一个简单的算法 帮忙转下Delhpi 的 谢谢各位 大侠了 ! |
浏览:2512 |
|
加入我的收藏 |
楼主: |
private string sign(string urlPath, Dictionary paramDic) { byte[] signatureKey = Encoding.ASCII.GetBytes("50001"); List list = new List(); foreach (KeyValuePair kv in paramDic) { list.Add(kv.Key + kv.Value); } list.Sort(); string tmp = urlPath; foreach (string kvstr in list) { tmp = tmp + kvstr; }
//HMAC-SHA1 HMACSHA1 hmacsha1 = new HMACSHA1(signatureKey); hmacsha1.ComputeHash(Encoding.ASCII.GetBytes(tmp)); /* hmacsha1.ComputeHash(Encoding.ASCII.GetBytes(urlPath)); foreach (string kvstr in list) { hmacsha1.ComputeHash(Encoding.ASCII.GetBytes(kvstr)); } */ byte[] hash = hmacsha1.Hash; //TO HEX return BitConverter.ToString(hash).Replace("-", string.Empty).ToUpper(); }
----------------------------------------------
~·~·~·~·~·~·~·~·~·~·· 我爱Delphi!不过马上就要要用C++Builder! ~·~·~·~·~·~·~·~·~·~·· |
|