我已经编写了一个快速控制台应用程序,可以快速为我的 Web 应用程序生成用户名和登录信息,以用于没有正确散列密码的现有帐户。在我的 Web 应用程序中,我正在使用 FormsAuthentication,如下所示:
string hashedPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(saltAndPassword, "SHA1");
我尝试在控制台应用程序中使用 FormsAuthentication,但它无法解析 FormsAuthentication 或导入。我收到的警告询问我是否缺少程序集。我尝试使用以下内容来给我与之前相同的结果:
SHA1 sha1 = new SHA1CryptoServiceProvider();
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] bytesHashedPwd = sha1.ComputeHash(encoding.GetBytes(saltAndPwd));
string tmpString = encoding.GetString(byteshashedPwd);
string hashedPwd = String.Concat(str, salt);
return hashedPwd;
这两种方法给了我不同的结果。我需要得到与 FormsAuthentication 相同的结果。我不是具有微薄背景的安全专家,而且我的字符集知识更差。我很感激任何帮助。