小编Joh*_*uit的帖子

如何在我的salt和哈希代码中使用SHA-512和Rfc2898DeriveBytes?

我对密码学很陌生,但学习.我已经从我的在线研究中拼凑了许多不同的建议,并且已经创建了我自己的类来处理相关数据的哈希,盐,键拉伸和比较/转换.

在研究了用于加密的内置.NET库之后,我发现我所拥有的只是SHA-1.但是我得出结论,因为我正在使用散列过程的多次迭代,所以它并不坏.那是对的吗?

但如果我想从更强大的SHA-512开始,我怎么能在下面的代码中实现它?提前致谢.

using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;

public class CryptoSaltAndHash
{
    private string strHash;
    private string strSalt;
    public const int SaltSizeInBytes = 128;
    public const int HashSizeInBytes = 1024;
    public const int Iterations = 3000;

    public string Hash { get { return strHash; } }
    public string Salt { get { return strSalt; } }

    public CryptoSaltAndHash(SecureString ThisPassword)
    {
        byte[] bytesSalt = new byte[SaltSizeInBytes];
        using (RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider())
        {
            crypto.GetBytes(bytesSalt);
        }
        strSalt = Convert.ToBase64String(bytesSalt); …
Run Code Online (Sandbox Code Playgroud)

c# hash cryptography salt sha

7
推荐指数
3
解决办法
3526
查看次数

标签 统计

c# ×1

cryptography ×1

hash ×1

salt ×1

sha ×1