/// <summary> /// Decrypts the data. /// </summary> /// <param name="value">The value.</param> /// <param name="context">The context.</param> /// <returns> /// The <see cref="T:byte[]"/>. /// </returns> private byte[] Unprotect(string value, HttpContextBase context) { if (string.IsNullOrWhiteSpace(value)) { return(null); } string prefix = value[0].ToString(); string purpose = this.GetMachineKeyPurposeFromPrefix(prefix, context); if (purpose == null) { return(null); } value = value.Substring(1); byte[] bytes = Convert.FromBase64String(value); try { return(MachineKey.Unprotect(bytes, purpose)); } catch (CryptographicException ex) { ValidationException?.Invoke(this, ex); return(null); } }