public string Decrypt(EncryptedValue encryptedValue) { var aes = new AesManaged { Key = Convert.FromBase64String(_key), Mode = CipherMode.CBC, Padding = PaddingMode.ISO10126, IV = Convert.FromBase64String(encryptedValue.IV) }; var decryptor = aes.CreateDecryptor(); var passwordBytes = Convert.FromBase64String(encryptedValue.Value); var decryptedBytes = decryptor.TransformFinalBlock(passwordBytes, 0, passwordBytes.Length); return Encoding.UTF8.GetString(decryptedBytes); }
public string Decrypt(EncryptedValue encryptedValue) { var aes = new AesManaged { Key = Convert.FromBase64String(_key), Mode = CipherMode.CBC, Padding = PaddingMode.ISO10126, IV = Convert.FromBase64String(encryptedValue.IV) }; var decryptor = aes.CreateDecryptor(); var passwordBytes = Convert.FromBase64String(encryptedValue.Value); var decryptedBytes = decryptor.TransformFinalBlock(passwordBytes, 0, passwordBytes.Length); return(Encoding.UTF8.GetString(decryptedBytes)); }
private static void DecryptJsonValue(JsonPasswordCrypto cryptoHandler, dynamic originalValue) { var valueToDecrypt = new EncryptedValue(originalValue.IV.Value, originalValue.Value.Value); var decryptedValue = cryptoHandler.Decrypt(valueToDecrypt); JObject valueToReplace = originalValue; valueToReplace.Replace(decryptedValue); }