public static string GetDataSummary(byte[] buf)
{
string str = string.Empty;
using (MD5 md5 = MD5.Create())
{
buf = md5.ComputeHash(buf);
for (int i = 0; i < buf.Length; i++)
str += buf[i].ToString("x");
}
return str;
}
// bkn, gtk, ldw
public static string GetAntiCSRFToken(byte[] skey,
int uType = 0 // 1-md5,0-int
)
{
int salt = 5381;
string token = string.Empty;
if (uType == 1)
{
string hash = (salt << 5).ToString();
string md5key = "tencentQQVIP123443safde&!%^%1282";
for (int i = 0; i < skey.Length; i++)
{
int asc = (sbyte)skey[i];
hash += ((salt << 5) + asc);
salt = asc;
}
token = GetDataSummary(Encoding.Default.GetBytes(hash += md5key));
}
else
{
for (int i = 0; i < skey.Length; i++)
salt += (salt << 5) + (sbyte)skey[i];
token = (salt & 2147483647).ToString();
}
return token;
}
C# 实现TX GTK算法
最新推荐文章于 2024-05-17 09:32:23 发布