Example #1
0
        /// <summary>
        /// AES算法解密
        /// </summary>
        /// <param name="cipherText">需要解密的Base64字符串</param>
        /// <param name="key">密匙</param>
        /// <returns>解密后的字符串</returns>
        /// <remarks>如果解密的字符串不是Base64编码格式,会报错.</remarks>
        /// <exception cref="System.ArgumentNullException">参数为空时,导致异常.</exception>
        public static string AesDecrypt(this string cipherText)
        {
            // Check arguments.
            if (cipherText == null || cipherText.Length == 0)
                throw new ArgumentNullException("cipherText");

            // Read the decrypted bytes from the decrypting stream and place them in expression string.
            return cipherText.AesDecrypt("[email protected]");
        }
Example #2
0
        /// <summary>
        /// AES算法解密
        /// </summary>
        /// <param name="cipherText">需要解密的Base64字符串</param>
        /// <param name="key">密匙</param>
        /// <returns>解密后的字符串</returns>
        /// <remarks>如果解密的字符串不是Base64编码格式,会报错.</remarks>
        /// <exception cref="System.ArgumentNullException">参数为空时,导致异常.</exception>
        public static string AesDecrypt(this string cipherText, string key)
        {
            // Check arguments.
            if (cipherText == null || cipherText.Length == 0)
                throw new ArgumentNullException("cipherText");
            if (key == null || key.Length < 1)
                throw new ArgumentNullException("Key");

            // Read the decrypted bytes from the decrypting stream and place them in expression string.
            return cipherText.AesDecrypt(key, "www.allyn.com.cn");
        }