简单适用的密码加密

许多密码都需要加密,加密不能够太简单,否则容易被破解,但是也不能够太负责,要不然为了加密结果却影响了性能,也不值得,下面这段代码是天天经常使用的一段加密代码。
注意:一般用户忘记密码时,应该通过条件重设新密码,而不是获取原密码,因为一般密码是不可逆的,也就是根据密文,得不到明文
    public static string Encrypt(string cleanString)
    {
        Byte[] clearBytes = new UnicodeEncoding().GetBytes(cleanString);
        Byte[] hashedBytes = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);

        return BitConverter.ToString(hashedBytes);
    }

 


这段代码将根据明文返回加密的密文。
原文地址:https://www.cnblogs.com/mqingqing123/p/949093.html