Exemplo n.º 1
0
        public void EncryptFile(string filePath, string encryptedFilePath, string password)
        {
            byte[] bytesToBeEncrypted = File.ReadAllBytes(filePath);
            byte[] passwordBytes      = Encoding.UTF8.GetBytes(password);

            // Hash the password with SHA256
            passwordBytes = SHA256.Create().ComputeHash(passwordBytes);

            byte[] bytesEncrypted = _aesHelper.AES_Encrypt(bytesToBeEncrypted, passwordBytes);
            File.WriteAllBytes(encryptedFilePath, bytesEncrypted);
        }