using MAX.Core.Cryptography;
using MAX.Core.Helpers;
using Store.Client;
using Store.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Client.Commons
{
///
/// 签名工具
///
public class SignTool
{
///
/// 获取签名
///
///
public static string GetSign()
{
long time = GetReviseUnix();
string s = Encryption(time);
return "time=" + time + "&code=" + s + "&NbCodeVersion=1";
}
///
/// 用户签名
///
///
public static string GetUserSign()
{
return GetUserSign("", "");
}
///
/// 获取当前用户签名
///
///
///
///
public static string GetUserSign(string shopId, string shopName)
{
long time = GetReviseUnix();
string time1 = Encryption(time);
return "time=" + time + "&code=" + time1 + "&NbCodeVersion=1" + "&uid=" + ClientInfo.User.UserId + "&key=" + ClientInfo.User.UserKey +
"&cid=" + ClientInfo.User.CompanyId + "&company=" + UrlHelper.Encode(ClientInfo.User.CompanyName) +
"&sid=" + shopId + "&shop=" + UrlHelper.Encode(shopName);
}
///
/// 获取校正后的时间戳
///
///
public static long GetReviseUnix()
{
return DateHelper.GetCurrentUnixTimestampInSeconds() + ServerConfig.TimeDifferent;
}
///
/// 签名算法
///
/// 随机数
/// 加密签名结果
public static string Encryption(long s)
{
string value = $"{s}sdhewu*/fhAAue48485ew5+5%@3485esGFFHFD";
return MD5Helper.Md5_32(value);
}
}
}