static byte[] GetBytes(string val) { #if NET_2_0 return(MachineKeySectionUtils.GetBytes(val, val.Length)); #else return(MachineKeyConfig.GetBytes(val, val.Length)); #endif }
public static FormsAuthenticationTicket Decrypt(string encryptedTicket) { if (encryptedTicket == null || encryptedTicket == String.Empty) { throw new ArgumentException("Invalid encrypted ticket", "encryptedTicket"); } Initialize(); FormsAuthenticationTicket ticket; #if NET_2_0 byte [] bytes = MachineKeySectionUtils.GetBytes(encryptedTicket, encryptedTicket.Length); #else byte [] bytes = MachineKeyConfig.GetBytes(encryptedTicket, encryptedTicket.Length); #endif try { ticket = Decrypt2(bytes); } catch (Exception) { ticket = null; } return(ticket); }