public string SignRequest(string url, byte[] reqBody)
{
Uri u = new Uri(url);
using (HMACSHA1 hmac = new HMACSHA1(Encoding.UTF8.GetBytes(this.SecretKey)))
{
string pathAndQuery = u.PathAndQuery;
byte[] pathAndQueryBytes = Encoding.UTF8.GetBytes(pathAndQuery);
using (MemoryStream buffer = new MemoryStream())
{
buffer.Write(pathAndQueryBytes, 0, pathAndQueryBytes.Length);
buffer.WriteByte((byte)'\n');
if (reqBody!=null && reqBody.Length > 0)
{
buffer.Write(reqBody, 0, reqBody.Length);
}
byte[] digest = hmac.ComputeHash(buffer.ToArray());
string digestBase64 = StringUtils.urlSafeBase64Encode(digest);
return string.Format("{0}:{1}", this.AccessKey, digestBase64);
}
}
}