예제 #1
0
        public static byte[] DecryptByteBlock(byte[] dataToDecrypt, byte[] password)
        {
            if (dataToDecrypt == null)
            {
                throw new ArgumentNullException("dataToDecrypt");
            }

            if (password == null)
            {
                throw new ArgumentNullException("password");
            }

            var aes = new Aes();

            var salt    = ByteHelpers.CreateSpecialByteArray(32);
            var message = ByteHelpers.CreateSpecialByteArray(dataToDecrypt.Length - 32);

            Buffer.BlockCopy(dataToDecrypt, 0, salt, 0, 32);
            Buffer.BlockCopy(dataToDecrypt, 32, message, 0, dataToDecrypt.Length - 32);

            var deCompressed = Compressor.Decompress(aes.Decrypt(message, password, salt, PBKDF2_ITERATIONS));

            return(deCompressed);
        }