/// <summary>
/// Unprotects the specified encrypted data by applying an decryption algorthim specified by the
/// <see cref="DataProtectionScope" />.
/// </summary>
/// <param name="encryptedData">The encrypted data.</param>
/// <param name="optionalEntropy">The optional entropy.</param>
/// <param name="scope">The scope.</param>
/// <returns>
/// The unencrypted byte array, otherwise the original encrypted byte array.
/// </returns>
/// <exception cref="ArgumentNullException">The encryptedData parameter is null.</exception>
/// <exception cref="CryptographicException">The cryptographic protection failed.</exception>
/// <exception cref="PlatformNotSupportedException">The operating system does not support this method.</exception>
/// <exception cref="OutOfMemoryException">Out of memory.</exception>
public static byte[] Unprotect(byte[] encryptedData, string optionalEntropy, DataProtectionScope scope)
{
byte[] salt = (!string.IsNullOrEmpty(optionalEntropy)) ? Encoding.Unicode.GetBytes(optionalEntropy) : null;
byte[] data = ProtectedData.Unprotect(encryptedData, salt, scope);
return(data);
}