public byte[] Serialize()
        {
            var result = new byte[16 + 8];

            Array.Copy(UserId.ToByteArray(), result, 16);
            Array.Copy(BitConverter.GetBytes(ValidThrough.Ticks), 0, result, 16, 8);
            return(result);
        }
Example #2
0
        /// <summary>
        /// Gets a unique base64 encoded, encrypted token representing the userId
        /// </summary>
        /// <returns></returns>
        public string GetEncryptedToken()
        {
            byte[] salt = Encoding.Unicode.GetBytes(ConfigurationManager.AppSettings["Crypto.Salt"]);
            byte[] data = UserId.ToByteArray();
            Random r    = new Random();

            byte[] d = new byte[4];
            r.NextBytes(d);
            data = d.Concat(data).ToArray();
            return(Crypto.Crypto.Encrypt(data, ConfigurationManager.AppSettings["Crypto.Password"], salt));
        }
Example #3
0
        protected override IEnumerable <byte[]> GetItems()
        {
            yield return(UserId.ToByteArray());

            yield return(Prismi.ToByteArray(true, true));

            yield return(Cmki.ToByteArray(true, true));

            yield return(PrismiAuth.ToByteArray());

            yield return(CmkiAuth.ToByteArray());

            yield return(Encoding.UTF8.GetBytes(Email));
        }
Example #4
0
 public override int GetHashCode()
 {
     return(BitConverter.ToInt32(UserId.ToByteArray(), 0));
 }