Ejemplo n.º 1
0
 /// <summary>
 /// AES解密(BouncyCastle模式)
 /// </summary>
 /// <param name="aes"></param>
 /// <param name="data">待解密的数据</param>
 /// <param name="mode">解密模式</param>
 /// <param name="padding">填充算法</param>
 /// <param name="key">密钥</param>
 /// <param name="iv">向量</param>
 /// <returns>解密后数据</returns>
 public static byte[] DecryptBC(this System.Security.Cryptography.Aes aes,
                                byte[] data, CipherModeBC mode, CipherPaddingBC padding, byte[] key = null, byte[] iv = null)
 {
     return(aes.CryptoBC(false, data, mode, padding, key, iv));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// AES加解密(BouncyCastle模式)
 /// </summary>
 /// <param name="aes"></param>
 /// <param name="forEncryption">是否加密(false为解密)</param>
 /// <param name="data">待加解密的数据</param>
 /// <param name="mode">加解密模式</param>
 /// <param name="padding">填充算法</param>
 /// <param name="key">密钥</param>
 /// <param name="iv">向量</param>
 /// <returns>加解密后数据</returns>
 public static byte[] CryptoBC(this System.Security.Cryptography.Aes aes,
                               bool forEncryption, byte[] data, CipherModeBC mode, CipherPaddingBC padding, byte[] key, byte[] iv)
 {
     return(aes.CryptoBC(forEncryption, data, $"AES/{mode}/{padding}", key, iv));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// AES解密(BouncyCastle模式)
 /// </summary>
 /// <param name="aes"></param>
 /// <param name="data">待解密的数据</param>
 /// <param name="algorithm">解密模式、填充算法</param>
 /// <param name="key">密钥</param>
 /// <param name="iv">向量</param>
 /// <returns>解密后数据</returns>
 public static byte[] DecryptBC(this System.Security.Cryptography.Aes aes,
                                byte[] data, string algorithm, byte[] key = null, byte[] iv = null)
 {
     return(aes.CryptoBC(false, data, algorithm, key, iv));
 }