下面是我生成签名的代码,有什么问题吗
仔细研究过文档了,文档连接就不用发了。
/// <summary>
/// 生成鉴权字符串
/// </summary>
/// <returns></returns>
public static string OrtData()
{
string appid = "APPID";
string bucket = "xkr";
string secret_id = "ECRETID";
long expired = timestamp() + 2592000;
long current = timestamp();
int rdm = 12341233;
string strOrgData = "a=["+appid+"]&b=["+bucket+"]&k=["+secret_id+"]&e=["+expired+"]&t=["+ current + "]&r=["+rdm+"]&u=[0]&f=";
return strOrgData;
}
/// <summary>
/// ORC身份识别API鉴权编码生成
/// </summary>
/// <returns></returns>
public static string SHA1key()
{
string strOrgData = OrtData();
string secret = "加密KEY";
String res1 = (String)ApiHelper.hash_hmac(strOrgData, secret);
return Convert.ToBase64String(Encoding.UTF8.GetBytes(res1+strOrgData));
}
/// <summary>
/// 生成时间戳
/// </summary>
/// <returns></returns>
public static long timestamp()
{
DateTime dt = DateTime.Now;
var start = new DateTime(1970, 1, 1, 0, 0, 0, dt.Kind);
return Convert.ToInt64((dt - start).TotalSeconds);
}
相似问题