C#调用DataV token代码
public static string GetUrl(string screenID, string token)
{
string time = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000).ToString();
String signature = CreateToken(screenID + "|" + time, token);
String url = "https://datav.aliyun.com/share/" + screenID + "?_datav_time="
+ time + "&_datav_signature=" + signature;
return url;
}
private static string CreateToken(string message, string secret)
{
secret = secret ?? "";
var encoding = new System.Text.ASCIIEncoding();
byte[] keyByte = encoding.GetBytes(secret);
byte[] messageBytes = encoding.GetBytes(message);
using (var hmacsha256 = new HMACSHA256(keyByte))
{
byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
return Convert.ToBase64String(hashmessage);
}
}