public string decrypt(byte[] encrypted, byte[] key, byte[] iv)
        {
            //Get a decryptor that uses the same key and IV as the encryptor.
            ICryptoTransform decryptor = desCSP.CreateDecryptor(key, iv);

            Symmetric symm = new Symmetric();

            return(symm.decrypt(decryptor, encrypted));
        }
        public byte[] encrypt(string plaintext, byte[] key, byte[] iv)
        {
            this.key = key;
            this.iv  = iv;
            // Get an encryptor.
            ICryptoTransform encryptor = desCSP.CreateEncryptor(key, iv);

            Symmetric symm = new Symmetric();

            return(symm.encrypt(encryptor, plaintext));
        }
Пример #3
0
        public string decrypt(byte[] encrypted, byte[] key, byte[] iv)
        {
            tripledesCSP.Mode = mode;
            tripledesCSP.Padding = padding;
            //MessageBox.Show(tripledesCSP.Mode + "/" + tripledesCSP.Padding);
            //Get a decryptor that uses the same key and IV as the encryptor.
            ICryptoTransform decryptor = tripledesCSP.CreateDecryptor(key, iv);

            Symmetric symm = new Symmetric();

            return symm.decrypt(decryptor, encrypted);
        }
        public string decrypt(byte[] encrypted, byte[] key, byte[] iv)
        {
            //Get a decryptor that uses the same key and IV as the encryptor.
            rc2CSP.Mode    = mode;
            rc2CSP.Padding = padding;
            MessageBox.Show(rc2CSP.Mode + "/" + rc2CSP.Padding);
            ICryptoTransform decryptor = rc2CSP.CreateDecryptor(key, iv);

            Symmetric symm = new Symmetric();

            return(symm.decrypt(decryptor, encrypted));
        }
        public byte[] encrypt(string plaintext, byte[] key, byte[] iv)
        {
            this.key       = key;
            this.iv        = iv;
            rc2CSP.Mode    = mode;
            rc2CSP.Padding = padding;
            MessageBox.Show(rc2CSP.Mode + "/" + rc2CSP.Padding);
            // Get an encryptor.
            ICryptoTransform encryptor = rc2CSP.CreateEncryptor(key, iv);
            Symmetric        symm      = new Symmetric();

            return(symm.encrypt(encryptor, plaintext));
        }
        public byte[] encrypt(string plaintext, byte[] key, byte[] iv)
        {
            this.key       = key;
            this.iv        = iv;
            desCSP.Mode    = mode;
            desCSP.Padding = padding;
            //MessageBox.Show(desCSP.Mode + "/" + desCSP.Padding);
            // Get an encryptor.
            try
            {
            }
            catch (Exception e)
            {
            }
            ICryptoTransform encryptor = desCSP.CreateEncryptor(key, iv);

            Symmetric symm = new Symmetric();

            return(symm.encrypt(encryptor, plaintext));
        }