public Stream Decrypt(EncryptedStream cipherStream) { byte[] cipherBytes = cipherStream.GetBytes(); byte[] iv = cipherStream.Iv; byte[] clearBytes = ProtectedData.Unprotect(cipherBytes, iv, DataProtectionScope.LocalMachine); return new MemoryStream(clearBytes); }
public Stream Decrypt(EncryptedStream cipherStream) { byte[] cipherBytes = cipherStream.GetBytes(); byte[] iv = cipherStream.Iv; byte[] clearBytes = ProtectedData.Unprotect(cipherBytes, iv, DataProtectionScope.LocalMachine); return(new MemoryStream(clearBytes)); }
public Stream Decrypt(EncryptedStream cipherStream) { _cipher.IV = cipherStream.Iv; using (ICryptoTransform transform = _cipher.CreateDecryptor()) { byte[] cipherBytes = cipherStream.GetBytes(); byte[] clearBytes = transform.TransformFinalBlock(cipherBytes, 0, cipherBytes.Length); return(new MemoryStream(clearBytes)); } }
public Stream Decrypt(EncryptedStream cipherStream) { _cipher.IV = cipherStream.Iv; using (ICryptoTransform transform = _cipher.CreateDecryptor()) { byte[] cipherBytes = cipherStream.GetBytes(); byte[] clearBytes = transform.TransformFinalBlock(cipherBytes, 0, cipherBytes.Length); return new MemoryStream(clearBytes); } }