コード例 #1
0
        public static string GetHashedToken(string httpVerb, string uriBase, string contentType, string dt, string qsParams, string body, string secretKey)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(httpVerb.ToUpper());
            sb.Append("\n");
            sb.Append(uriBase);
            sb.Append("\n");
            sb.Append(contentType ?? String.Empty);
            sb.Append("\n");
            sb.Append(dt);
            sb.Append("\n");
            sb.Append(qsParams ?? String.Empty);
            sb.Append("\n");
            sb.Append(body ?? String.Empty);

            string signatureInput = sb.ToString();

            return(HmacCrypto.HashedToken(secretKey, signatureInput.Replace("\\", "")));
        }
コード例 #2
0
        /// <summary>
        /// Create Auth String
        /// </summary>
        /// <param name="first">true = first item in QueryString, false = not first item</param>
        /// <param name="guid">key to be used with the timestamp for the signature</param>
        /// <param name="privateKey">private key for the signature</param>
        /// <returns>string of Authentication Guid, Timestamp, and Signature</returns>
        public static string AuthString(bool first, bool unix, string key, string privateKey)
        {
            string ts = null;

            if (unix == true)
            {
                ts = DateTime.Now.ToUnixTimestamp();
            }
            else
            {
                ts = DateTime.Now.ToUniversalTime().ToString();
            }

            //String privateKey, String guid, String dateStamp

            string qs           = first == true ? "?" : "&";
            string urlAuthKeyTS = qs + "key=" + key + "&timestamp=" + ts;
            string urlAuth      = urlAuthKeyTS + "&signature=" + HmacCrypto.Signature(privateKey, key, ts);

            return(urlAuth);
        }