예제 #1
0
        private static string GenerateRequestToken(string playerId, string secret)
        {
            Serializer serializer = new Serializer();

            serializer.AddString("userId", playerId);
            serializer.Add <long>("expires", GameUtils.GetNowJavaEpochTime());
            string text = serializer.End().ToString();

            byte[] value = CryptographyUtils.ComputeHmacHash("HmacSHA256", secret, text);
            string str   = BitConverter.ToString(value).Replace("-", string.Empty);

            return(Convert.ToBase64String(Encoding.UTF8.GetBytes(str + "." + text)));
        }
예제 #2
0
 private string GenerateHashedURL()
 {
     byte[] array = CryptographyUtils.ComputeHmacHash("HmacSHA256", "fd84f83863a613bf37fa", this.urlString.ToString());
     this.urlString.AppendFormat(CultureInfo.InvariantCulture, "{0}{1}=", new object[]
     {
         this.HasParameter() ? "&" : "?",
         "authorization"
     });
     byte[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         byte b = array2[i];
         this.urlString.Append(QueryURLBuilder.BYTE2HEXCHAR[(b & 240) >> 4]);
         this.urlString.Append(QueryURLBuilder.BYTE2HEXCHAR[(int)(b & 15)]);
     }
     return(this.urlString.ToString());
 }