コード例 #1
0
 public string GetSign(string text)
 {
     byte[] data = Encoding.ASCII.GetBytes(text);
     byte[] hash = HmacSha.ComputeHash(data);
     return(BitConverter.ToString(hash).Replace("-", string.Empty).ToLower());
     //StringBuilder builder = new StringBuilder();
     //for(int i = 0; i < hash.Length; i++)
     //    builder.Append(hash[i].ToString("x2", CultureInfo.InvariantCulture));
     //return builder.ToString();
 }
コード例 #2
0
        public string GetSign(string text)
        {
            byte[]        data    = Encoding.UTF8.GetBytes(text);
            byte[]        hash    = HmacSha.ComputeHash(data, 0, data.Length);
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < hash.Length; i++)
            {
                builder.Append(hash[i].ToString("x2", CultureInfo.InvariantCulture));
            }
            return(builder.ToString());
        }