【发布时间】:2013-06-14 15:08:56
【问题描述】:
我有一个纯文本形式的用户表,并将其迁移到成员资格提供程序。
使用 ColdFusion(当前系统)我设法对一个用户的密码(测试用户)进行哈希处理,并且它完美匹配。但是现在后面的用户不匹配。我做错了什么。
<cfscript>
theEncoding = "UTF-16LE";
thePassword = "dtD3v310p3r!";
base64Salt = "JZjdzUXREM0A7DPI3FV3iQ==";
theSalt = charsetEncode( binaryDecode(base64Salt, "base64"), theEncoding );
theHash = hash(theSalt & thePassword, "SHA1", theEncoding);
// hash always returns hex. convert it to base64 so it matches DNN
theBase64Hash = binaryEncode(binaryDecode(theHash, "hex"), "base64");
WriteOutput("<br />theBase64Hash= "& theBase64Hash &"<br/>");
WriteOutput("DBPassword= 5khDDMmoFtW+j99r/whE/TjyIUo= <br />");
theEncoding = "UTF-16LE";
thePassword = "DT!@12";
base64Salt = "+muo6gAmjvvyy5doTdjyaA==";
theSalt = charsetEncode( binaryDecode(base64Salt, "base64"), theEncoding );
theHash = hash(theSalt & thePassword, "SHA1", theEncoding);
// hash always returns hex. convert it to base64 so it matches DNN
theBase64Hash = binaryEncode(binaryDecode(theHash, "hex"), "base64");
WriteOutput("<br />theBase64Hash= "& theBase64Hash &"<br/>");
WriteOutput("DBPassword= nfcqQBgeAm0Dp1oGZI0O70Y6DvA= <br />");
</cfscript>
第一个工作 100%。但第二个没有。
第二个产生的哈希值为86SrPKXW5xywDYoC8MVy0q259sQ=
【问题讨论】:
-
您使用的盐是否正确?
-
@MattBusche - 我相信他正在尝试将数据库中的哈希与 ColdFusion 进行匹配。您将在他的代码示例中看到它正在打印生成的 ColdFusion 散列和我认为他从数据库中复制的“DBPassword”散列。第一个匹配,第二个不匹配(我尚未确认)。
-
是的,两者都来自 HASH 来自 Membership 表。我选择了前 2 名来拉记录。所以我不可能犯了复制错误哈希的错误。
标签: sql-server-2005 coldfusion asp.net-membership coldfusion-9