Ejemplo n.º 1
0
        private ICryptoTransform CreateDecryptor(byte[] key, AesKeySize keySize = AesKeySize.Aes128, PaddingMode paddingMode = PaddingMode.PKCS7)
        {
            Aes aes = new Aes(key.Copy(), keySize);

            aes.PaddingMode           = paddingMode;
            aes.RemovePaddingFunction = PaddingFactory.GetRemovePaddingFunction(paddingMode);
            aes.InitializeRoundKey();
            return(new AesDecryptor(aes));
        }
Ejemplo n.º 2
0
            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));
            }