- 论坛徽章:
- 0
|
多谢retuor!
我把在.net下调试的相关数据都发出来:
// .net 加密实现过程
internal string EncodePassword(string pass, int passwordFormat, string salt)
{
if (passwordFormat == 0) // MembershipPasswordFormat.Clear
return pass;
byte[] bIn = Encoding.Unicode.GetBytes(pass);
byte[] bSalt = Convert.FromBase64String(salt);
byte[] bAll = new byte[bSalt.Length + bIn.Length];
byte[] bRet = null;
Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length);
Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length);
if (passwordFormat == 1)
{ // MembershipPasswordFormat.Hashed
// 执行这里,使用SHA1算法加密
HashAlgorithm s = HashAlgorithm.Create( Membership.HashAlgorithmType );
bRet = s.ComputeHash(bAll);
} else
{
bRet = EncryptPassword( bAll );
}
return Convert.ToBase64String(bRet);
}
参数:
pass
"111111"
salt
"lOsxLBVLM1rz9jl/rdLdhQ=="
变量值:
bIn
{维数:[12]}
[0]: 49
[1]: 0
[2]: 49
[3]: 0
[4]: 49
[5]: 0
[6]: 49
[7]: 0
[8]: 49
[9]: 0
[10]: 49
[11]: 0
bSalt
{维数:[16]}
[0]: 148
[1]: 235
[2]: 49
[3]: 44
[4]: 21
[5]: 75
[6]: 51
[7]: 90
[8]: 243
[9]: 246
[10]: 57
[11]: 127
[12]: 173
[13]: 210
[14]: 221
[15]: 133
bAll
{维数:[28]}
[0]: 148
[1]: 235
[2]: 49
[3]: 44
[4]: 21
[5]: 75
[6]: 51
[7]: 90
[8]: 243
[9]: 246
[10]: 57
[11]: 127
[12]: 173
[13]: 210
[14]: 221
[15]: 133
[16]: 49
[17]: 0
[18]: 49
[19]: 0
[20]: 49
[21]: 0
[22]: 49
[23]: 0
[24]: 49
[25]: 0
[26]: 49
[27]: 0
result:
"0WUSbhDIJnai6BYP309b3uPe/ig=" |
|