如何在ASP.Net应用程序上使用Salting + hash? [英] How can I use salting+hashing on my ASP.Net application?

查看:89
本文介绍了如何在ASP.Net应用程序上使用Salting + hash?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从头开始构建项目,我想以Right Way™做事.我已经在网上阅读了有关散列的信息,基本上是在用64个字母组成的巨型密码转换密码,对吗?

I'm building a project from the ground up and I want to do things the Right Way™. I've read online about hashes and that's basically turning a password in 64 letters of mumbo jumbo, correct?

盐腌怎么样?

我的问题是:

  1. 如何使用C#对字符串进行哈希处理?
  2. MSSQL中的字段声明类型是什么? nvarchar(64)?
  3. 什么是盐腌,我需要将其保存在数据库中吗?
  4. 如果我想让人们使用Facebook Connect,我是否需要担心创建哈希/盐?

首选代码示例.谢谢!

推荐答案

1)代码

   public static string HashStringSha1(string plainText, string salt)
        {
            using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider())
            {
                byte[] bb = sha1.ComputeHash(Encoding.UTF8.GetBytes(salt + plainText + plainText));
                return Convert.ToBase64String(bb);
            }
        }

2)将base64字符串存储在SQLserver varchar中

2) Store base64 string in SQLserver varchar

3)将盐与哈希值存储在不同的字段中.盐为纯文本.

3) Store the salt in a different field with the hash. Salt as plain text.

4)不确定您的意思.如果使用OpenId,则不需要存储密码.

4) Not sure what you mean. If you use OpenId, you do not need to store passwords.

这篇关于如何在ASP.Net应用程序上使用Salting + hash?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆