转帖 3DEX加密

来源:互联网 发布:云计算与大数据龙头股 编辑:程序博客网 时间:2024/06/06 04:08
public static string Encrypt3DES(string strString, string strKey)
        {
            TripleDESCryptoServiceProvider provider = new TripleDESCryptoServiceProvider();
            provider.Key = new MD5CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(strKey));
            provider.Mode = CipherMode.ECB;
            ICryptoTransform transform = provider.CreateEncryptor();
            byte[] bytes = Encoding.ASCII.GetBytes(strString);
            byte[] returnValue = transform.TransformFinalBlock(bytes, 0, bytes.Length);
            return Convert.ToBase64String(returnValue);
        }
原创粉丝点击