Utilities/CryptHelper.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.Text;

namespace Utilities
{
    public class CryptHelper
    {
        static string Key = "huotian";

        public static string Encrypt(string str)
        {
            if (string.IsNullOrEmpty(str)) return str;

            StringBuilder r = new StringBuilder();
            string s = Key + str;
            byte[] s1 = Encoding.UTF8.GetBytes(s);
            for (int i = 0; i < s1.Length; i++)
            {
                r.Append((s1[i] * 3).ToString().PadLeft(3, '0'));
                //r.AppendFormat("{0}%", s1[i]);
            }
            return r.ToString();
        }

        public static string Decrypt(string str)
        {
            if (string.IsNullOrEmpty(str)) return str;
            
            List<byte> bs = new List<byte>();
            //string[] ss = str.Split('%');
            //for (int i = 0; i < ss.Length - 1; i++)
            //{
            //    bs.Add(Convert.ToByte(ss[i]));
            //}
            for (int i = 0; i < str.Length; i +=3)
            {
                int b = Convert.ToInt32(str.Substring(i, 3));
                bs.Add(Convert.ToByte(b / 3));
            }
            byte[] s1 = bs.ToArray();
            string s = Encoding.UTF8.GetString(s1);
            string r = s.Substring(Key.Length);
            return r;
        }
    }
}

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

AI 解读 AI

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

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