转帖 3DEX加密

来源:互联网 发布:迈腾轮毂尺寸数据 编辑:程序博客网 时间:2024/06/07 08:40
    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);
        }