ClrPlus.Core.Extensions.StringExtensions.UnprotectBinaryForUser C# (CSharp) Method

UnprotectBinaryForUser() public static method

decrypts the given collection of bytes with the user key and salt (defaults to "CoAppToolkit") returns an empty collection of bytes on failure
public static UnprotectBinaryForUser ( this binaryData, string salt = "CoAppToolkit" ) : IEnumerable
binaryData this The binary data.
salt string The salt.
return IEnumerable
        public static IEnumerable<byte> UnprotectBinaryForUser(this IEnumerable<byte> binaryData, string salt = "CoAppToolkit") {
            if (binaryData.IsNullOrEmpty()) {
                return Enumerable.Empty<byte>();
            }

            try {
                return ProtectedData.Unprotect(binaryData.ToArray(), salt.ToByteArray(), DataProtectionScope.CurrentUser);
            } catch {
                /* suppress */
            }
            return Enumerable.Empty<byte>();
        }