public string Decrypt(EncryptedText cipherText) { byte[] cipherBytes = cipherText.GetBytes(); byte[] iv = cipherText.Iv; byte[] clearBytes = ProtectedData.Unprotect(cipherBytes, iv, DataProtectionScope.LocalMachine); return Encoding.UTF8.GetString(clearBytes); }
public string Decrypt(EncryptedText cipherText) { byte[] cipherBytes = cipherText.GetBytes(); byte[] iv = cipherText.Iv; byte[] clearBytes = ProtectedData.Unprotect(cipherBytes, iv, DataProtectionScope.LocalMachine); return(Encoding.UTF8.GetString(clearBytes)); }
public string Decrypt(EncryptedText cipherText) { _cipher.IV = cipherText.Iv; using (ICryptoTransform transform = _cipher.CreateDecryptor()) { byte[] cipherBytes = cipherText.GetBytes(); byte[] clearBytes = transform.TransformFinalBlock(cipherBytes, 0, cipherBytes.Length); return(Encoding.UTF8.GetString(clearBytes)); } }
public string Decrypt(EncryptedText cipherText) { _cipher.IV = cipherText.Iv; using (ICryptoTransform transform = _cipher.CreateDecryptor()) { byte[] cipherBytes = cipherText.GetBytes(); byte[] clearBytes = transform.TransformFinalBlock(cipherBytes, 0, cipherBytes.Length); return Encoding.UTF8.GetString(clearBytes); } }