{
//使用SHA1的HMAC
HMAC hmac = HMACSHA1.Create();
var publicKey = "/data/?areaid={0}&type={1}&date={2}&appid={3}";
var data = System.Text.Encoding.UTF8.GetBytes(string.Format(publicKey, areaId, type, date, appid));
//密鑰
var key = System.Text.Encoding.UTF8.GetBytes(privateKey);
hmac.Key = key;
//對數據進行簽名
var signedData = hmac.ComputeHash(data);
return Convert.ToBase64String(signedData);
}
參考資料:blogs.com/aptdo2008/p/3566391.html