Common/Tools.cs

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;
using System.Security.Cryptography;

namespace SSO.Common
{
    /// <summary>
    /// 公共
    /// </summary>
    public static class Tools
    {
        /// <summary>
        /// 获取带令牌请求的URL(Passport服务器)
        /// 在当前URL中附加上令牌请求参数
        /// </summary>
        /// <returns></returns>
        public static string TokenUrl()
        {
            string url = HttpContext.Current.Request.Url.AbsoluteUri;
            Regex reg = new Regex(@"^.*\?.+=.+$");
            if (reg.IsMatch(url))
                url += "&token=$token$";
            else
                url += "?token=$token$";

            return "http://www.passport.com/gettoken.aspx?backurl=" + System.Web.HttpUtility.UrlEncode(url);
        }

        /// <summary>
        /// 去掉backurl中的令牌
        /// 并返回passport登录地址
        /// </summary>
        /// <returns></returns>
        public static string TokenReplace()
        {
            string url = HttpContext.Current.Request.Url.AbsoluteUri;
            url = Regex.Replace(url, @"(\?|&)Token=.*", "", RegexOptions.IgnoreCase);
            return "http://www.passport.com/userlogin.aspx?backurl=" + System.Web.HttpUtility.UrlEncode(url);
        }

        public static string EnAes(string plainText)
        {
            byte[] key = new byte[32] { 22, 22, 22, 22, 33, 33, 33, 33, 44, 44, 44, 44, 55, 55, 55, 55, 66, 97, 45, 81, 85, 192, 67, 58, 185, 198, 33, 72, 153, 52, 76, 29 };
            byte[] iv = new byte[16] { 55, 55, 33, 44, 66, 66, 185, 47, 90, 109, 74, 58, 185, 168, 33, 72 };
            return Convert.ToBase64String(enAes(plainText, key, iv));
        }

        public static string DeAes(string cipherText)
        {
            byte[] key = new byte[32] { 22, 22, 22, 22, 33, 33, 33, 33, 44, 44, 44, 44, 55, 55, 55, 55, 66, 97, 45, 81, 85, 192, 67, 58, 185, 198, 33, 72, 153, 52, 76, 29 };
            byte[] iv = new byte[16] { 55, 55, 33, 44, 66, 66, 185, 47, 90, 109, 74, 58, 185, 168, 33, 72 };
            return deAes(Convert.FromBase64String(cipherText), key, iv);
        }

        private static byte[] enAes(string plainText, byte[] key, byte[] iv)
后面还有 76 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。