178 lines
4.9 KiB
C#
178 lines
4.9 KiB
C#
using Newtonsoft.Json;
|
|
using OpenCVForUnity.UnityUtils;
|
|
using Org.BouncyCastle.Ocsp;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.Networking;
|
|
using WpfApp1.Util;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
public class SetJson : MonoBehaviour
|
|
{
|
|
public static SetJson instance;
|
|
|
|
public string AesKey = "kGBxaThxMCMGaysp";
|
|
|
|
public string VersionNumber = "1.0.0";
|
|
|
|
public string url = "https://www.baidu.com/";
|
|
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
// 输出查看url查询数据部分结构
|
|
// M.DrowQRCode("https://www.baidu.com/");
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 从文件NewConfig.ini获取url地址
|
|
/// </summary>
|
|
public string ReadUrl()
|
|
{
|
|
string url_ = "";
|
|
File.ReadAllLines(Application.streamingAssetsPath + "/NewConfig.ini").ToList().ForEach(a =>
|
|
{
|
|
if (!a.StartsWith("#") && !string.IsNullOrEmpty(a) && a.Contains("url="))
|
|
{
|
|
string[] tmp = a.Split('=');
|
|
Debug.Log(tmp);
|
|
if (tmp[0].Trim() == "url")
|
|
{
|
|
url_ = tmp[1].Trim();
|
|
Debug.Log(url_);
|
|
}
|
|
}
|
|
});
|
|
return url_;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 从文件NewConfig.ini获取当前使用得语言
|
|
/// </summary>
|
|
public string ReadLanguage()
|
|
{
|
|
string Language_ = "";
|
|
File.ReadAllLines(Application.streamingAssetsPath + "/NewConfig.ini").ToList().ForEach(a =>
|
|
{
|
|
if (!a.StartsWith("#") && !string.IsNullOrEmpty(a) && a.Contains("Language="))
|
|
{
|
|
string[] tmp = a.Split('=');
|
|
Debug.Log(tmp);
|
|
if (tmp[0].Trim() == "Language")
|
|
{
|
|
Language_ = tmp[1].Trim();
|
|
Debug.Log(Language_);
|
|
}
|
|
}
|
|
});
|
|
return Language_;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 从文件NewConfig.ini获取当前场景
|
|
/// </summary>
|
|
public string ReadScenceName()
|
|
{
|
|
string ScenceName = "";
|
|
File.ReadAllLines(Application.streamingAssetsPath + "/NewConfig.ini").ToList().ForEach(a =>
|
|
{
|
|
if (!a.StartsWith("#") && !string.IsNullOrEmpty(a) && a.Contains("Scence="))
|
|
{
|
|
string[] tmp = a.Split('=');
|
|
Debug.Log(tmp);
|
|
if (tmp[0].Trim() == "Scence")
|
|
{
|
|
ScenceName = tmp[1].Trim();
|
|
Debug.Log(ScenceName);
|
|
}
|
|
}
|
|
});
|
|
return ScenceName;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 加密
|
|
/// </summary>
|
|
/// <param name="VerificationCode">验证码</param>
|
|
/// <param name="Data">日期</param>
|
|
/// <param name="VersionNumber">版本号</param>
|
|
/// <param name="AesKey">密钥</param>
|
|
/// <returns></returns>
|
|
public string AssemblyField(string VerificationCode,string Data,string VersionNumber,string AesKey)
|
|
{
|
|
PortList br = new PortList { VerificationCode = VerificationCode , Data = Data , VersionNumber = VersionNumber };
|
|
return "?param1=" + AESHelper.AesEncrypt(JsonConvert.SerializeObject(br), AesKey);
|
|
}
|
|
|
|
/*
|
|
/// <summary>
|
|
/// 解密
|
|
/// </summary>
|
|
/// <param name="VerificationCode">验证码</param>
|
|
/// <param name="Data">日期</param>
|
|
/// <param name="VersionNumber">版本号</param>
|
|
/// <param name="AesKey">密钥</param>
|
|
/// <returns></returns>
|
|
public string AssemblyField(string VerificationCode,string Data,string VersionNumber,string AesKey)
|
|
{
|
|
PortList br = new PortList { VerificationCode = VerificationCode, Data = Data, VersionNumber = VersionNumber };
|
|
return "?param1=" + AESHelper.AesEncrypt(JsonConvert.SerializeObject(br), AesKey);
|
|
}
|
|
*/
|
|
|
|
/// <summary>
|
|
/// 生成验证码
|
|
/// </summary>
|
|
/// <param name="VerificationCode">验证码</param>
|
|
/// <returns></returns>
|
|
public string GenerateVerificationCode()
|
|
{
|
|
System.Random random = new System.Random();
|
|
string chars = "0123456789ABCDEFGHIJKLM0123456789NOPQRSTUVWXYZ0123456789abcdefghijklm0123456789nopqrstuvwxyz0123456789";
|
|
char[] stringChars = new char[6];
|
|
for (int i = 0; i < stringChars.Length; i++)
|
|
{
|
|
stringChars[i] = chars[random.Next(chars.Length)];
|
|
}
|
|
string finalString = new String(stringChars);
|
|
return finalString;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#region JSON
|
|
[System.Serializable]
|
|
public class PortList
|
|
{
|
|
/// <summary>
|
|
/// 验证码
|
|
/// </summary>
|
|
[Tooltip("验证码")] public string VerificationCode;
|
|
/// <summary>
|
|
/// 日期
|
|
/// </summary>
|
|
[Tooltip("日期")] public string Data;
|
|
/// <summary>
|
|
/// 版本号
|
|
/// </summary>
|
|
[Tooltip("版本号")] public string VersionNumber;
|
|
}
|
|
#endregion |