WCF / REST散列/盐领域的数据成员 [英] WCF/REST hash/salt datamember field

查看:137
本文介绍了WCF / REST散列/盐领域的数据成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datacontract和我的服务,我想哈希/盐密码数据成员:

I have a datacontract and in my service I am trying to hash/salt the password datamember:

    public void AddStudent(Student student)
    {
        student.StudentID = (++eCount).ToString();
        byte[] passwordHash = Hash(student.Password, _passwordSalt); //invalid expression? _passwordSalt?
        student.TimeAdded = DateTime.Now;
        students.Add(student);
    }

谁能帮助?

推荐答案

尝试使用此功能 GenerateSalt()来替换 _passwordSalt 从我的项目之一:

Try to replace the _passwordSalt with this function GenerateSalt() from one of my projects:

protected RNGCryptoServiceProvider random = new RNGCryptoServiceProvider();

public byte[] GenerateSalt() {
    byte[] salt = new byte[10];
    random.GetNonZeroBytes(salt);
    return salt;
}

这是你必须拯救这个生成的盐的方式。你所需要的相同的盐每次检查密码。

By the way you have to save this generated salt. You need the same salt every time to check the password.

这篇关于WCF / REST散列/盐领域的数据成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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