protected override byte[] ProviderUnprotect(byte[] encryptedData) { // Delegate to ProtectedData return(ProtectedData.Unprotect(encryptedData, GetHashedPurpose(), Scope)); }
/// <summary> /// Protects the specified data by applying an encryption algorthim specified by the <see cref="DataProtectionScope" />. /// </summary> /// <param name="unencryptedData">The unencrypted data.</param> /// <param name="optionalEntropy">The optional entropy.</param> /// <param name="scope">The scope.</param> /// <returns>The encrypted data in a 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">The system ran out of memory while encrypting the data.</exception> public static byte[] Protect(byte[] unencryptedData, string optionalEntropy, DataProtectionScope scope) { byte[] salt = (!string.IsNullOrEmpty(optionalEntropy)) ? Encoding.Unicode.GetBytes(optionalEntropy) : null; byte[] data = ProtectedData.Protect(unencryptedData, salt, scope); return(data); }
protected override byte[] ProviderProtect(byte[] userData) { // Delegate to ProtectedData return(ProtectedData.Protect(userData, GetHashedPurpose(), Scope)); }