private ICryptoTransform CreateEncryptor(byte[] key, AesKeySize keySize = AesKeySize.Aes128, PaddingMode paddingMode = PaddingMode.PKCS7) { Aes aes = new Aes(key.Copy(), keySize); aes.PaddingMode = paddingMode; aes.PaddingFunction = PaddingFactory.GetPaddingFunction(paddingMode); aes.InitializeRoundKey(); return(new AesEncryptor(aes)); }
public static ICryptoTransform CreateEncryptor(byte[] key, byte[] IV, AesKeySize keySize = AesKeySize.Aes128, PaddingMode paddingMode = PaddingMode.PKCS7) { Aes aes = new Aes(key.Copy(), IV.Copy(), keySize); aes.PaddingMode = paddingMode; aes.PaddingFunction = PaddingFactory.GetPaddingFunction(paddingMode); aes.EncryptMode = EncryptModeEnum.CBC; aes.InitializeRoundKey(); return(new AesCBCEncryptor(aes)); }