public static String Issue(String data, TimeSpan validFor, Int32 maxUses) { if (data.Length > 90) throw new ArgumentException("The data for the token cannot be longer than 90 characters"); DateTime issued = UtcDateTime.Now; DateTime expires = issued.Add(validFor); data = Guid.NewGuid().ToString() + "," + data + "," + expires.Ticks; TextEncryption crypto = new TextEncryption(GooeyConfigManager.TokenEncyrptionKey); String result = crypto.Encrypt(data); SecurityToken token = new SecurityToken(); token.Token = result; token.Issued = issued; token.Expires = expires; token.Uses = 0; token.MaxUses = maxUses; SaveToDatabase(token); return result; }
public static String Encrypt(String text) { TextEncryption crypto = new TextEncryption(); return crypto.Encrypt(text); }
private static void SetEncryptedSiteConfiguration(String key, String value) { TextEncryption crypto = new TextEncryption(CurrentSite.Guid.Value); String encryptedValue = crypto.Encrypt(value); SetSiteConfiguration(key, encryptedValue); }