internal static byte[] Decode(CookieProtection cookieProtection, string data, Purpose purpose)
        {
            byte[] buf = HttpServerUtility.UrlTokenDecode(data);
            if (AspNetCryptoServiceProvider.Instance.IsDefaultProvider)
            {
                // If we're configured to go through the new crypto routines, do so.
                ICryptoService cryptoService = AspNetCryptoServiceProvider.Instance.GetCryptoService(purpose);
                return(cryptoService.Unprotect(buf));
            }

#pragma warning disable 618 // calling obsolete methods
            // Otherwise fall back to using MachineKeySection.
            if (buf == null || cookieProtection == CookieProtection.None)
            {
                return(buf);
            }
            if (cookieProtection == CookieProtection.All || cookieProtection == CookieProtection.Encryption)
            {
                buf = MachineKeySection.EncryptOrDecryptData(false, buf, null, 0, buf.Length);
                if (buf == null)
                {
                    return(null);
                }
            }

            if (cookieProtection == CookieProtection.All || cookieProtection == CookieProtection.Validation)
            {
                return(MachineKeySection.GetUnHashedData(buf));
            }
            return(buf);

#pragma warning restore 618 // calling obsolete methods
        }
 internal static byte[] Decode(CookieProtection cookieProtection, string data)
 {
     byte[] buf = HttpServerUtility.UrlTokenDecode(data);
     if ((buf == null) || (cookieProtection == CookieProtection.None))
     {
         return(buf);
     }
     if ((cookieProtection == CookieProtection.All) || (cookieProtection == CookieProtection.Encryption))
     {
         buf = MachineKeySection.EncryptOrDecryptData(false, buf, null, 0, buf.Length);
         if (buf == null)
         {
             return(null);
         }
     }
     if ((cookieProtection != CookieProtection.All) && (cookieProtection != CookieProtection.Validation))
     {
         return(buf);
     }
     return(MachineKeySection.GetUnHashedData(buf));
 }