Пример #1
0
        /// <summary>
        /// Initialize the class as a Block Cipher
        /// </summary>
        /// <param name="Cipher">Block Cipher instance</param>
        /// <param name="KeyParam">Key and vector material</param>
        /// <param name="Mode">Cipher mode</param>
        /// <param name="Padding">Padding type</param>
        public Transform(IBlockCipher Cipher, KeyParams KeyParam, CipherModes Mode = CipherModes.CTR, PaddingModes Padding = PaddingModes.X923)
        {
            this.KeyParam = KeyParam;

            if (Mode == CipherModes.CBC)
                this.CipherMode = new CBC(Cipher);
            else
                this.CipherMode = new CTR(Cipher);

            if (Padding == PaddingModes.PKCS7)
                this.Padding = new PKCS7();
            else if (Padding == PaddingModes.X923)
                this.Padding = new X923();

            this.IsStream = false;
        }
Пример #2
0
 /// <summary>
 /// Initialize the class as a Stream Cipher
 /// </summary>
 /// <param name="Cipher">Stream Cipher instance</param>
 /// <param name="KeyParam">Key and vector material</param>
 public Transform(IStreamCipher Cipher, KeyParams KeyParam)
 {
     this.KeyParam = KeyParam;
     this.StreamCipher = Cipher;
     this.IsStream = true;
 }