コード例 #1
0
ファイル: AesEncryptor.cs プロジェクト: ArdyFoolen/Aes
        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));
        }
コード例 #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));
            }