加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sql-server-2005 – [Sql-Server]什么数据类型用于密码salt和has

发布时间:2020-12-12 16:32:49 所属栏目:MsSql教程 来源:网络整理
导读:我从我的密码生成盐和哈希值使用, string salt = CreateSalt(TxtPassword.Text.Length);string hash = CreatePasswordHash(TxtPassword.Text,salt);private static string CreateSalt(int size){ //Generate a cryptographic random number. RNGCryptoService
我从我的密码生成盐和哈希值使用,
string salt = CreateSalt(TxtPassword.Text.Length);
string hash = CreatePasswordHash(TxtPassword.Text,salt);

private static string CreateSalt(int size)
{
    //Generate a cryptographic random number.
    RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
    byte[] buff = new byte[size];
    rng.GetBytes(buff);

    // Return a Base64 string representation of the random number.
    return Convert.ToBase64String(buff);
}

private static string CreatePasswordHash(string pwd,string salt)
{
    string saltAndPwd = String.Concat(pwd,salt);
    string hashedPwd =
     FormsAuthentication.HashPasswordForStoringInConfigFile(
     saltAndPwd,"sha1");

    return hashedPwd;
}

您建议在sql server中存储这些值的数据类型?任何建议…

盐:9GsPWpFD

哈希:E778AF0DC5F2953A00B35B35D80F6262CDBB8567

解决方法

ASPNET_DB说这个 – 不能出错.
Password nvarchar(128) NOT NULL,PasswordSalt nvarchar(128) NOT NULL,

而128可能看起来很多,各种类型的加密可能会导致比您开始的更大的字符串.绝对没有理由不跟随那些花费数千小时开发asp.net会员制的非常聪明的人.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读