//----------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Generates the key with the temporal and computer specific attributes /// </summary> protected StringBuilder GenerateKey() { //-----a----- Start building the encrypted string StringBuilder tokenToEncrypt = new StringBuilder(); tokenToEncrypt.Append(MGLEncryption.GetSalt(1)); //-----b----- Double check that the anonID cookie has been set and set it again if not... (this should never not have happened as it is called first OnInit in the MGLBasePage) SetAnonIDCookie(); //-----c----- The AnonID is a GUID - always 36 characters string tempValue = DefaultAnonID; if (Request.Cookies["AnonID"] != null) { tempValue = Request.Cookies["AnonID"].Value; } tokenToEncrypt.Append(tempValue); //-----d----- Add some padding tokenToEncrypt.Append(MGLEncryption.GetSalt(1)); //-----e----- The date time will be of the form yyyy-mm-dd hh:mm:ss - and will always be dd and mm (not d and m for e.g. 01) tokenToEncrypt.Append(DateTimeInformation.FormatDatabaseDate(DateTime.Now, true, true)); tokenToEncrypt.Append(MGLEncryption.GetSalt(1)); //-----f----- Do the encryption itself StringBuilder authKey = MGLEncryption.Encrypt(tokenToEncrypt); //-----g----- And lastly, lets make this key HTML secure ... authKey = MGLEncryption.HTMLifyString(authKey); return(authKey); }