Beispiel #1
0
        public static string GetMailLinkQueryString(string code, int userId)
        {
            // 32-bit block cipher. +https://github.com/eleven41/Eleven41.Skip32
            //var cipher = new Eleven41.Skip32.Skip32Cipher(Encoding.ASCII.GetBytes(skip32Key));
            //var encrypted = cipher.Encrypt(userId);
            //// Convert to UInt32 to avoid a sign.
            //var bytes = BitConverter.GetBytes(encrypted);
            //var unsigned = BitConverter.ToUInt32(bytes, 0);
            //var encryptedString = unsigned.ToString();
            var encryptedString = Skip32Utils.EncriptIntToHexString(userId, skip32Key);

            return(CodeKey + "=" + HttpUtility.UrlEncode(code) + "&" + UserIdKey + "=" + HttpUtility.UrlEncode(encryptedString));
        }
Beispiel #2
0
 public static int GetUserIdFromQueryStringValue(string queryStringValue)
 {
     //uint unsigned;
     //if (UInt32.TryParse(queryStringValue, out unsigned))
     //{
     //    var bytes = BitConverter.GetBytes(unsigned);
     //    var encrypted = BitConverter.ToInt32(bytes, 0);
     //    var cipher = new Eleven41.Skip32.Skip32Cipher(Encoding.ASCII.GetBytes(skip32Key));
     //    return cipher.Decrypt(encrypted);
     //}
     //else
     //    return 0;
     return(Skip32Utils.DecriptHexStringToInt(queryStringValue, skip32Key, 0));
 }