1.机器码为明文,采用DES加密
2.判断输入激活码与机器码的密文一致,激活成功


using UnityEngine;
using UnityEngine.UI;using UnityEngine.SceneManagement;
using System.IO;namespace KeyScene
{public class KeyMgr : MonoBehaviour{public string m_titleName;public string m_projectName;string m_sMachineCode;public string m_nextScene;public Text m_machineCode;public InputField m_inputActice;public Text m_title;public UnityEngine.UI.Button m_btnCopy;public UnityEngine.UI.Button m_btnActive;public Text m_hint;string m_miMa;string m_path;string m_fileName = "mi.json";string m_allPath;public GameObject m_panel;// Use this for initializationvoid Start(){m_sMachineCode = m_projectName + SystemInfo.deviceUniqueIdentifier;m_miMa = DesTool.EncryptString(m_sMachineCode, "subor123");Debug.Log(m_miMa);m_path = UnityEngine.Application.streamingAssetsPath;m_allPath = m_path + "/" + m_fileName;if (File.Exists(m_allPath) == true){string sContent = GetJsonString(m_allPath);if (sContent == m_miMa){SceneManager.LoadScene(m_nextScene);}else {m_panel.SetActive(true);}}else {m_panel.SetActive(true);}m_machineCode.text = m_sMachineCode;m_title.text = m_titleName;m_btnActive.onClick.AddListener(OnBtnActive);m_btnCopy.onClick.AddListener(OnBtnCopy);}void OnBtnActive(){string active = m_inputActice.text;if (active == m_miMa){m_hint.text = "激活成功";m_hint.color = Color.green;m_hint.gameObject.SetActive(true);m_panel.SetActive(false);//保存文本SaveJsonString(active, m_allPath);SceneManager.LoadScene(m_nextScene);}else {m_hint.text = "激活失败";m_hint.color = Color.red;m_hint.gameObject.SetActive(true);}}void OnBtnCopy(){System.Windows.Forms.Clipboard.SetDataObject(m_sMachineCode);}static public void SaveJsonString(string JsonString, string path)    //保存Json格式字符串{//写入Json数据if (File.Exists(path) == true){File.Delete(path);}string onlyPath = GetOnlyPath(path);if (!Directory.Exists(onlyPath)){Directory.CreateDirectory(onlyPath);}FileInfo file = new FileInfo(path);StreamWriter writer = file.CreateText();writer.Write(JsonString);writer.Close();writer.Dispose();}static public string GetJsonString(string path)     //从文件里面读取json数据{//读取Json数据StreamReader reader = new StreamReader(path);string jsonData = reader.ReadToEnd();reader.Close();reader.Dispose();return jsonData;}public static string GetOnlyPath(string path){string[] bufPath = path.Split('/');string name = bufPath[bufPath.Length - 1];string onlyPath = path.Replace(name, "");//string abPath = info.m_prefabName.Replace("/" + abName, "");//string[] bufAbName = abName.Split('.');return onlyPath;}}
}

Des加密类

using System.IO;
using System.Text;
using System.Security.Cryptography;
using System;public class DesTool  {#region 密钥//private static string key = "abcd1234";                                   //密钥(长度必须8位以上)   #endregion#region DES加密public static string EncryptString(string pToEncrypt,string key){DESCryptoServiceProvider des = new DESCryptoServiceProvider();byte[] inputByteArray = Encoding.UTF8.GetBytes(pToEncrypt);des.Key = UTF8Encoding.UTF8.GetBytes(key);des.IV = UTF8Encoding.UTF8.GetBytes(key);MemoryStream ms = new MemoryStream();CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);cs.Write(inputByteArray, 0, inputByteArray.Length);cs.FlushFinalBlock();StringBuilder ret = new StringBuilder();foreach (byte b in ms.ToArray()){ret.AppendFormat("{0:X2}", b);}ret.ToString();return ret.ToString();}#endregion#region DES解密public static string DecryptString(string pToDecrypt,string key){DESCryptoServiceProvider des = new DESCryptoServiceProvider();byte[] inputByteArray = new byte[pToDecrypt.Length / 2];for (int x = 0; x < pToDecrypt.Length / 2; x++){int i = (Convert.ToInt32(pToDecrypt.Substring(x * 2, 2), 16));inputByteArray[x] = (byte)i;}des.Key = UTF8Encoding.UTF8.GetBytes(key);des.IV = UTF8Encoding.UTF8.GetBytes(key);MemoryStream ms = new MemoryStream();CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);cs.Write(inputByteArray, 0, inputByteArray.Length);cs.FlushFinalBlock();StringBuilder ret = new StringBuilder();return Encoding.UTF8.GetString(ms.ToArray());}#endregion
}

unity3d:激活码系统(根据PC机器码,给对应激活码完成软件注册)相关推荐

  1. office2016每次弹激活_win10系统office2016激活后仍弹出激活怎么解决

    现阶段,许多win10系统用户都会在自己的win10系统中安装office2016办公软件吗,而且安装完成之后也会进行激活操作,但是有些用户在使用已激活的office2016时偶尔会弹出激活窗口,这让 ...

  2. 云转码系统搭配服务器,服务器做云转码

    服务器做云转码 内容精选 换一换 对于已安装Cloud-Init/Cloudbase-Init的云服务器,首次执行切换/故障切换操作,或者创建容灾演练后,系统第一次启动时会运行Cloud-Init/C ...

  3. 赋码系统服务器数据库的用途,人工智能赋码方法及系统

    主权项: 1.人工智能赋码方法,其特征在于,包括:①印设个性特征图案--在商品⑵上开设个性特征区⑶并在个性特征区⑶内印设肉眼可见的随机点或/和线或/和面,从而在每一件商品⑵上形成至少一个.在预定数量内 ...

  4. 华睿相机sdk 开发_告别翻转腾挪,读码一步到位丨华睿科技六面读码系统

    随着制造业的智能化发展和电子商务的急剧扩张,中国物流行业正在从传统物流迈向智慧物流时代.分拣作为物流配送的重要环节,决定了整个物流运输的最终效率.如何提升物流分拣效率?华睿科技给出了答案. 华睿科技六 ...

  5. 计算机毕业设计Java-超市会员积分管理系统-(源码+系统+mysql数据库+lw文档)

    计算机毕业设计Java-超市会员积分管理系统-(源码+系统+mysql数据库+lw文档) 计算机毕业设计Java-超市会员积分管理系统-(源码+系统+mysql数据库+lw文档) 本源码技术栈: 项目 ...

  6. JAVA计算机毕业设计书籍点评网站源码+系统+mysql数据库+lw文档

    JAVA计算机毕业设计书籍点评网站源码+系统+mysql数据库+lw文档 JAVA计算机毕业设计书籍点评网站源码+系统+mysql数据库+lw文档 本源码技术栈: 项目架构:B/S架构 开发语言:Ja ...

  7. 基于JAVA中小型饭馆餐饮管理系统计算机毕业设计源码+系统+数据库+lw文档+部署

    基于JAVA中小型饭馆餐饮管理系统计算机毕业设计源码+系统+数据库+lw文档+部署 基于JAVA中小型饭馆餐饮管理系统计算机毕业设计源码+系统+数据库+lw文档+部署 本源码技术栈: 项目架构:B/S ...

  8. 计算机毕业设计Java河池市旅游信息系统(源码+系统+mysql数据库+lw文档)

    计算机毕业设计Java河池市旅游信息系统(源码+系统+mysql数据库+lw文档) 计算机毕业设计Java河池市旅游信息系统(源码+系统+mysql数据库+lw文档) 本源码技术栈: 项目架构:B/S ...

  9. 基于JAVA养老院管理系统计算机毕业设计源码+系统+数据库+lw文档+部署

    基于JAVA养老院管理系统计算机毕业设计源码+系统+数据库+lw文档+部署 基于JAVA养老院管理系统计算机毕业设计源码+系统+数据库+lw文档+部署 本源码技术栈: 项目架构:B/S架构 开发语言: ...

  10. 计算机毕业设计springboot基于疫情背景下的新型点餐送餐系统bpe1s源码+系统+程序+lw文档+部署

    计算机毕业设计springboot基于疫情背景下的新型点餐送餐系统bpe1s源码+系统+程序+lw文档+部署 本源码技术栈: 项目架构:B/S架构 开发语言:Java语言 开发软件:idea ecli ...

最新文章

  1. java冒泡排序_Java中的经典算法之冒泡排序(Bubble Sort)
  2. matplotlib中plot的颜色
  3. 【完结】如何学习AutoML在模型优化中的应用,这12篇文章可以作为一个参考
  4. Java中的ExceptionInInitializerError异常及解决方法
  5. 生产环境常见的HTTP状态码列表
  6. Ajax4Jsf 简单介绍
  7. 如何请教问题且以后都会回答你的方法
  8. 百度地图添加自定义shp图层_GIS当中使用uDig打开shp图层,并查看数据结果
  9. 为什么 C 语言仍然占据统治地位?
  10. 升级Big sur后提示没有权限来打开应用程序(注册机类),该怎么办
  11. Java显示smart3d数据_Smart3D系列教程 | smart3d空三错乱的解决办法
  12. 七大行星排列图片_太阳系八大行星大小及排列顺序
  13. 第11课:词句分布式表达——词建模工具
  14. VMware更改虚拟机网卡的MAC地址
  15. JVM中类加载的时机
  16. 分布式事务讲解 -消息队列+定时任务+本地事件表
  17. 利用幂级数性质解级数求和问题
  18. 微信小程序搭建新闻列表(跟进上一篇博客案例)
  19. QS2016年全球高等教育系统实力排名 中国排名世界第八亚洲第一
  20. Windows10剪切板快捷键

热门文章

  1. 屏幕坐标转换成threejs的坐标
  2. 计算机教研论文范文,计算机教研论文提纲格式模板 计算机教研论文提纲怎样写...
  3. Base64编码原理分析
  4. 基于php的超市仓库管理系统
  5. 决策树cart算法实战
  6. 微信点餐 创建订单报外键错误
  7. 【动画消消乐|CSS】083.纯CSS实现卡通齿轮效果
  8. KEIL4与KEIL5护眼配色方案
  9. BigGAN高保真自然图像合成的大规模GAN训练
  10. 蚂蚁分类信息使用心得