【发布时间】:2017-03-18 07:51:07
【问题描述】:
我有一张表,其中包含 Telerik Sitefinity 系统的登录凭据。我想使用相同的登录凭据,但使用没有 Sitefinity 库的不同应用程序。我正在努力使用密码编码,它设置为哈希(默认为 SHA1 算法)。
我尝试使用以下代码对密码进行编码,但它与 Sitefinity 生成的不匹配。
public string EncodePassword(string pass, string salt)
{
byte[] bytes = Encoding.Unicode.GetBytes(pass);
byte[] src = Convert.FromBase64String(salt);
byte[] dst = new byte[src.Length + bytes.Length];
Buffer.BlockCopy(src, 0, dst, 0, src.Length);
Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length);
HashAlgorithm algorithm = HashAlgorithm.Create("SHA1");
byte[] inArray = algorithm.ComputeHash(dst);
return Convert.ToBase64String(inArray);
}
示例:
密码:password111
SALT:94EBE09530D9F5FAE3D002A4BF262D2F(保存在 SF 用户表中)
上面函数的哈希:8IjcFO4ad8BdkD40NJcgD0iGloU=
SF:A24GuU8OasJ2bicvT/E4ZiKfAT8=生成的表中的哈希值
我已经在网上搜索过SF生成的编码密码是否不同,但找不到任何结果。如何在没有 SF 库的情况下使用 SF 创建的登录凭据?
【问题讨论】:
标签: c# hash passwords sha1 sitefinity