public void SignString() { HmacSHA1Signer instance = new HmacSHA1Signer(); string sign = instance.SignString("foo", "secret"); Assert.Equal("m67ZG+f1i1fIJLYNp8smKy7K+9I=", sign); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="signString"></param> private void AddHeader(HttpRequestMessage request, string signString) { var timeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(); request.Headers.Add("Spas-AccessKey", _accessKey); request.Headers.Add("timeStamp", $"{timeStamp}"); request.Headers.Add("Spas-Signature", _hmacSHA1.SignString($"{signString}+{timeStamp}", _secretKey)); }