相关疑难解决方法(0)

ToString("X2")的含义是什么?

我正在研究加密MD5,我在谷歌找到了这个代码

    public string CalculateMD5Hash(string input)
    {

        // Primeiro passo, calcular o MD5 hash a partir da string
        MD5 md5 = System.Security.Cryptography.MD5.Create();
        byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
        byte[] hash = md5.ComputeHash(inputBytes);

        // Segundo passo, converter o array de bytes em uma string haxadecimal
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < hash.Length; i++)
        {
            sb.Append(hash[i].ToString("X2"));
        }
        return sb.ToString();
    }
Run Code Online (Sandbox Code Playgroud)

但为什么它使用ToString("X2")?ToString正常有什么区别?

c# encryption tostring

76
推荐指数
3
解决办法
8万
查看次数

算法复杂性和安全性:MD5还是SHA1?

在复杂性和安全性方面,哪种是最佳的整体哈希算法?md5还是sha1?

据我所知,md5比sha1快,但SHA1比md5更复杂.

我错过了什么吗?

algorithm hash

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

Scrypt和Cryptsharp的示例代码

我在Google上搜索过,我找不到使用Cryptsharp库的Scrypt用法代码示例(用于哈希密码).

你能提供哈希密码的样本吗?

c# encryption cryptography scrypt

8
推荐指数
1
解决办法
8965
查看次数

使用VB.NET的ASP.NET中的AES

什么是使用AES加密URL链接以使用VB.NET 2005将用户名传递到ASP.NET中的另一个网站的好链接或文章?仅供参考:接收网站将有权访问私钥以进行解密.

asp.net encryption cryptography aes

4
推荐指数
1
解决办法
2万
查看次数

为什么哈希字符串的示例通常使用 Encoding.UTF8?

引用的代码来自这个答案,但类似的代码几乎无处不在。假设我们需要使用System.Security.Cryptography.HashAlgorithm.ComputeHash()接受byte[]. 典型的代码是这样的:

public static byte[] GetHash(string inputString)
{
    HashAlgorithm algorithm = MD5.Create();  // SHA1.Create()
    return algorithm.ComputeHash(Encoding.UTF8.GetBytes(inputString));
}
Run Code Online (Sandbox Code Playgroud)

字符串在内部存储为 Unicode。

为什么Encoding.UTF8用 代替Encoding.Unicode?

.net c# unicode hash encoding

3
推荐指数
1
解决办法
1685
查看次数

标签 统计

c# ×3

encryption ×3

cryptography ×2

hash ×2

.net ×1

aes ×1

algorithm ×1

asp.net ×1

encoding ×1

scrypt ×1

tostring ×1

unicode ×1