小编Jai*_*ain的帖子

加密和解密

我想使用SHA1进行加密.我的代码是

public static string EncryptPassword(string password)
{
    try
    {
        SHA1 sha1 = new SHA1Managed();
        var bytehash = sha1.ComputeHash(new MemoryStream(new ASCIIEncoding().GetBytes(password)));
        var stringhash = new ASCIIEncoding().GetChars(bytehash).ToString();

        return stringhash;
    }
    catch (Exception ex)
    {
        // Some Exception....
    }

    return null;
}
Run Code Online (Sandbox Code Playgroud)

它不起作用.它只返回System.Char [].我在这做错了什么

c# encryption sha1

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

标签 统计

c# ×1

encryption ×1

sha1 ×1