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

UnprotectBinaryForMachine() public static method

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

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