Ejemplo n.º 1
0
        public override byte[] Encrypt(byte[] s, byte[] initVector, string password)
        {
            byte[] keyBytes      = new byte[keySize];
            byte[] passwordBytes = Encoding.ASCII.GetBytes(password);
            Buffer.BlockCopy(passwordBytes, 0, keyBytes, 0, Math.Min(keySize, passwordBytes.Length));

            byte[] iv = new byte[ivSize];
            Buffer.BlockCopy(initVector, 0, iv, 0, Math.Min(ivSize, iv.Length));

            using (MCryptEncryptor crypto = new MCryptEncryptor(NativeConstants.MCRYPT_RIJNDAEL_128, keyBytes, iv))
            {
                byte[] outBuf = crypto.Encrypt(s);
                return(outBuf);
            }
        }
Ejemplo n.º 2
0
        public override byte[] Encrypt(byte[] s, byte[] initVector, string password)
        {
            byte[] keyBytes = new byte[keySize];
            byte[] passwordBytes = Encoding.ASCII.GetBytes(password);
            Buffer.BlockCopy(passwordBytes, 0, keyBytes, 0, Math.Min(keySize, passwordBytes.Length));

            byte[] iv = new byte[ivSize];
            Buffer.BlockCopy(initVector, 0, iv, 0, Math.Min(ivSize, iv.Length));

            using (MCryptEncryptor crypto = new MCryptEncryptor(NativeConstants.MCRYPT_BLOWFISH, keyBytes, iv))
            {
                byte[] outBuf = crypto.Encrypt(s);
                return outBuf;
            }
        }