71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 签名工具
|
|
/// </summary>
|
|
public class SignTool
|
|
{
|
|
/// <summary>
|
|
/// 获取签名
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string GetSign()
|
|
{
|
|
long time = GetReviseUnix();
|
|
string s = Encryption(time);
|
|
return "time=" + time + "&code=" + s + "&NbCodeVersion=1";
|
|
}
|
|
/// <summary>
|
|
/// 用户签名
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string GetUserSign()
|
|
{
|
|
return GetUserSign("", "");
|
|
}
|
|
/// <summary>
|
|
/// 获取当前用户签名
|
|
/// </summary>
|
|
/// <param name="shopId"></param>
|
|
/// <param name="shopName"></param>
|
|
/// <returns></returns>
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取校正后的时间戳
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static long GetReviseUnix()
|
|
{
|
|
return DateHelper.GetCurrentUnixTimestampInSeconds() + ServerConfig.TimeDifferent;
|
|
}
|
|
/// <summary>
|
|
/// 签名算法
|
|
/// </summary>
|
|
/// <param name="s">随机数</param>
|
|
/// <returns>加密签名结果</returns>
|
|
public static string Encryption(long s)
|
|
{
|
|
string value = $"{s}sdhewu*/fhAAue48485ew5+5%@3485esGFFHFD";
|
|
return MD5Helper.Md5_32(value);
|
|
}
|
|
}
|
|
}
|