byte[] ipadArray = new byte[64];
byte[] opadArray = new byte[64];
byte[] keyArray = new byte[64];
System.Security.Cryptography.SHA1 sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
// SHA1 sha1 = null;
int ex = key.Length;
if (key.Length > 64)
{
byte[] temp = sha1.ComputeHash(strToToHexByte(key));
ex = temp.Length;
for (int i = 0; i < ex; i++)
{
keyArray[i] = temp[i];
}
}
else
{
byte[] temp = strToToHexByte(key);
for (int i = 0; i < temp.LongLength; i++)
{
keyArray[i] = temp[i];
}
}
for (int i = ex; i < 64; i++)
{
keyArray[i] = 0;
}
for (int j = 0; j < 64; j++)
{
ipadArray[j] = (byte)(keyArray[j] ^ 0x36);
opadArray[j] = (byte)(keyArray[j] ^ 0x5C);
}
byte[] tempResult = sha1.ComputeHash(join(ipadArray, strToToHexByte(data)));
return sha1.ComputeHash(join(opadArray, tempResult));
}
聯(lián)系客服