/// <summary> /// 解密字符串,输入BASE64编码字符串 /// </summary> /// <param name="source">要解密的BASE64编码字符串</param> /// <param name="key">密钥字符串,长度为8或者24</param> /// <returns>解密的明文字符串</returns> public static string Decrypt(string source, string key) { source.CheckNotNullOrEmpty(nameof(source)); key.CheckNotNullOrEmpty(nameof(key)); var keyBytes = Encoding.UTF8.GetBytes(key); var des = new DesHelper(keyBytes); return(des.Decrypt(source)); }
/// <summary> /// 解密字节数组 /// </summary> /// <param name="source">要解密的字节数组</param> /// <param name="key">密钥字节数组,长度为8或者24</param> /// <returns>解密后的字节数组</returns> public static byte[] Decrypt(byte[] source, byte[] key) { var des = new DesHelper(key); return(des.Decrypt(source)); }