当前位置: 首页 > wzjs >正文

做软件赚钱还是做网站赚钱成都新一轮疫情

做软件赚钱还是做网站赚钱,成都新一轮疫情,没有备案号的网站,网站建设策划范文1、参数类似于“XXXXX://?userIdsystem&time1696830378038&token38a8ea526537766f01ded33a6cdfa5bd” 2、在config里加一个LoginSecret参数可随意指定一个字符串 3、BS登录代码里会对“LoginSecret的参数值用户ID时间戳”进行MD5加密形成token,与传过来的…

1、参数类似于XXXXX://?userId=system&time=1696830378038&token=38a8ea526537766f01ded33a6cdfa5bd

2、在config里加一个LoginSecret参数可随意指定一个字符串

3、BS登录代码里会对“LoginSecret的参数值+用户ID+时间戳”进行MD5加密形成token,与传过来的Token进行比对,一致才通过,同时对时间戳进行校验,时间的有效性为3分钟,也就是时间戳代表的时间+3分钟后,若大于当前时间则校验通过。通过后,直接以传过来的用户名登录BS,否则弹出提示信息。

以下为示例代码:

public static class TokenUtil

{

private static readonly string LIVE_SECRET = "6132E474arKk56ed3384310265O876ql";

public static string GenerateToken(string userId, long time)
{
    string text = LIVE_SECRET + userId + time;
    return GetMd5Hash(text);
}

public static bool ValidateToken(string userId, string time, string token)
{
    if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(time) || string.IsNullOrEmpty(token))
    {
        return false;
    }
    if (TimestampToDateTime(time).AddMinutes(3) < DateTime.Now)
    {
        return false;
    }

    string text = LIVE_SECRET + userId + time;
    string loginSecret =ConfigurationManager.AppSettings["LoginSecret"];
    if (!string.IsNullOrEmpty(loginSecret))
        text = loginSecret + userId + time;

    string validateToken = GetMd5Hash(text);

    return token.Equals(validateToken, StringComparison.OrdinalIgnoreCase);
}
private static string GetMd5Hash(string input)
{
    using (MD5 md5 = MD5.Create())
    {
        byte[] inputBytes = Encoding.UTF8.GetBytes(input);
        byte[] hashBytes = md5.ComputeHash(inputBytes);
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < hashBytes.Length; i++)
        {
            sb.Append(hashBytes[i].ToString("x2"));
        }

        return sb.ToString();
    }
}
/// <summary>
/// 本时区日期时间转时间戳
/// </summary>
/// <param name="datetime"></param>
/// <returns>long=Int64</returns>
public static long ToTimestamp(this DateTime datetime)
{
    DateTime dd = new DateTime(1970, 1, 1, 0, 0, 0, 0);
    DateTime timeUTC = DateTime.SpecifyKind(datetime, DateTimeKind.Utc);//本地时间转成UTC时间
    TimeSpan ts = (timeUTC - dd);
    return (Int64)(ts.TotalMilliseconds);//精确到毫秒
}
/// <summary>
/// 时间戳转本时区日期时间
/// </summary>
/// <param name="timeStamp"></param>
/// <returns></returns>
public static DateTime TimestampToDateTime(this string timeStamp)
{
    DateTime dd = DateTime.SpecifyKind(new DateTime(1970, 1, 1, 0, 0, 0, 0), DateTimeKind.Local);
    long longTimeStamp = long.Parse(timeStamp + "0000");
    TimeSpan ts = new TimeSpan(longTimeStamp);
    return dd.Add(ts);
}

}

调用:

public partial class Login

{

 private string strTempUser;

protected override void OnLoad( EventArgs e )

{

PageLoad("Login");

try
{
    if (Request["userId"] != null && Request["time"] != null && Request["token"] != null)
    {
        if (TokenUtil.ValidateToken(Request["userId"].ToString(), Request["time"].ToString(), Request["token"].ToString()))
        {
            strTempUser = Request["userId"].ToString();
            User u = UsersDirectory.GetUser(strTempUser);
            if (u != null)
            {
                Account account = new Account(u);
                Logined(account);
            }
            else 
            {
                throw new Exception("用户不存在");
            }
        }
        else
        {
            throw new Exception("Token校验不通过");
        }
    }
}
catch
{
}

}

}

http://www.dtcms.com/wzjs/236099.html

相关文章:

  • 哪些企业网站做得好搜狗推广管家
  • 17网站一起做网店档口出租百度风云榜电视剧排行榜
  • 秦皇岛黄金海岸介绍seo排名系统
  • 微信网站建设价格信息检索关键词提取方法
  • 赤峰住房城乡建设部网站深圳网络营销策划公司
  • 商检局做产地证的网站百度seo优化培训
  • 手机移动端网站网络广告公司
  • 寿光网站制作谷歌seo营销
  • 做科技汽车的视频网站有哪些短视频seo营销系统
  • wordpress+3.2.1漏洞东莞seo整站优化火速
  • 可靠的南京网站建设象山关键词seo排名
  • html做简单网站实例企业推广网络营销
  • 做淘客网站需要备案吗网络营销成功的案例分析
  • 中小企业网站营销上海最新新闻
  • 西安网站优化万网域名注册官网查询
  • 网站闭关保护怎么做百度关键词竞价
  • 做论坛网站 备案企业网络营销策略分析
  • 保险网站建设的目标做一个企业网站需要多少钱
  • ftp网站上传成功后怎么做青岛网站建设推广公司
  • 网站怎么做才能将名声打响海外短视频跨境电商平台是真的吗
  • 鱼台做网站多少钱在哪里推广比较好
  • 建设网站需要哪些素材百度平台客服人工电话
  • 网站框架设计产品线上推广方案
  • 建站行业都扁平化设计百度人工电话
  • 解除网站被拦截的方法北京口碑最好的教育机构
  • 做网站的人 优帮云seo整站优化多少钱
  • 今日拉萨重大新闻代做seo关键词排名
  • 网站怎么做跳转页面西安seo引擎搜索优化
  • 网上商城网站建设体会最近的国际新闻大事
  • 制作一个购物网站b站2023年免费入口