Browse Source

改为预案密钥加密

develop
曹衍涛 4 years ago
parent
commit
43379420dd
  1. 8
      Assets/BaoLiJia.meta
  2. 8
      Assets/BaoLiJia/Scene.meta
  3. 8
      Assets/BaoLiJia/Scene/Materials.meta
  4. 78
      Assets/BaoLiJia/Scene/Materials/shui.mat
  5. 8
      Assets/BaoLiJia/Scene/Materials/shui.mat.meta
  6. 8
      Assets/Common/River.meta
  7. BIN
      Assets/Common/River/River_Normalmap.png
  8. 132
      Assets/Common/River/River_Normalmap.png.meta
  9. BIN
      Assets/Freighter/Scene/Materials/River.mat
  10. 73
      Assets/Plugins/SmartX1App.dll.meta
  11. BIN
      Assets/Plugins/SmartX1AppX64.dll
  12. 27
      Assets/Plugins/SmartX1AppX64.dll.meta
  13. BIN
      Assets/Scene/StartScene.unity
  14. 40
      Assets/Scripts/HelpScripts/CloneGameObjInfo.cs
  15. 1
      Assets/Scripts/HelpScripts/CloneObjType.cs
  16. 2
      Assets/Scripts/HelpScripts/QuitApplicationManager.cs
  17. 3
      Assets/Scripts/HelpScripts/QuitApplicationManager.cs.meta
  18. 12
      Assets/Scripts/HelpScripts/TransformHelper.cs
  19. 73
      Assets/Scripts/SmartX1/ApplicationClose.cs
  20. 11
      Assets/Scripts/SmartX1/ApplicationClose.cs.meta
  21. 5
      Assets/Scripts/SmartX1/SmartApp.cs.meta
  22. 296
      Assets/Scripts/SmartX1/SmartController.cs
  23. 5
      Assets/Scripts/SmartX1/SmartController.cs.meta
  24. 45
      Assets/Scripts/SmartX1/SmartX1.prefab
  25. 7
      Assets/Scripts/SmartX1/SmartX1.prefab.meta
  26. 36
      Assets/Scripts/SmartX1/SmartX1Api.cs
  27. 5
      Assets/Scripts/SmartX1/SmartX1Api.cs.meta
  28. BIN
      Assets/Sky/Materials/azure[Sky].mat
  29. 2
      Assets/StreamingAssets/xml/enSmartXProject.xml
  30. 7
      Assets/StreamingAssets/xml/enSmartXProject.xml.meta
  31. 2
      Assets/StreamingAssets/xml/enValidity.xml
  32. 7
      Assets/StreamingAssets/xml/enValidity.xml.meta

8
Assets/BaoLiJia.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 542bce6e7756745439cbcc326e95d36d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/BaoLiJia/Scene.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ced571f55d3952a439071ba30c584839
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/BaoLiJia/Scene/Materials.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c6fd56c4cf5c25546a13f05849f34f9f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

78
Assets/BaoLiJia/Scene/Materials/shui.mat

@ -0,0 +1,78 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: shui
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON _DETAIL_MULX2 _NORMALMAP
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 2800000, guid: 1f3fa1d35b6cef64ca00a0b92c488a80, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 10, y: 5}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 2800000, guid: 1f3fa1d35b6cef64ca00a0b92c488a80, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 20, y: 20}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 20, y: 20}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _GlossMapScale: 1
- _Glossiness: 0.91
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 3
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 0.2865343, g: 0.44339618, b: 0.43843237, a: 0.35686275}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 0}

8
Assets/BaoLiJia/Scene/Materials/shui.mat.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e6b1c013adbb50c4e9326050a2f42e99
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Common/River.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f3d16e563c55b574ba4c4f698e9077de
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Common/River/River_Normalmap.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 MiB

132
Assets/Common/River/River_Normalmap.png.meta

@ -0,0 +1,132 @@
fileFormatVersion: 2
guid: 1f3fa1d35b6cef64ca00a0b92c488a80
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 2
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 1
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Freighter/Scene/Materials/River.mat

Binary file not shown.

73
Assets/Plugins/SmartX1App.dll.meta

@ -1,27 +1,88 @@
fileFormatVersion: 2
guid: 0da92b84a3197f54681e93a2576be223
timeCreated: 1551513530
licenseType: Pro
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
data:
first:
- first:
'': Any
second:
enabled: 0
settings:
Exclude Editor: 1
Exclude Linux: 0
Exclude Linux64: 0
Exclude LinuxUniversal: 0
Exclude OSXUniversal: 0
Exclude Win: 0
Exclude Win64: 0
- first:
Any:
second:
enabled: 1
settings: {}
data:
first:
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 1
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: x86_64
- first:
Standalone: LinuxUniversal
second:
enabled: 1
settings: {}
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Plugins/SmartX1AppX64.dll

Binary file not shown.

27
Assets/Plugins/SmartX1AppX64.dll.meta

@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 0a982d274fd319c429332954ac197479
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Scene/StartScene.unity

Binary file not shown.

40
Assets/Scripts/HelpScripts/CloneGameObjInfo.cs

@ -63,25 +63,27 @@ public class CloneGameObjInfo : BaseGameObjInfo
}
private static void UpdateEnabled(FloorData data, CloneGameObjInfo obj)
{
if (obj.floorNum == 0)
{
if (!data.isOn)
{
obj.ShoworHidden = true;
}
else
{
if (data.floorNum > obj.floorNum)
{
obj.ShoworHidden = true;
}
else if (data.floorNum < obj.floorNum)
{
obj.ShoworHidden = false;
}
}
}
else if (data.buildNum == obj.buildNum)
if (string.IsNullOrEmpty(obj.buildNum))//室外物体不隐藏
return;
//if (obj.floorNum == 0)
//{
// //if (!data.isOn)
// //{
// // obj.ShoworHidden = true;
// //}
// //else
// //{
// // if (data.floorNum > obj.floorNum)
// // {
// obj.ShoworHidden = true;
// // }
// // else if (data.floorNum < obj.floorNum)
// // {
// // obj.ShoworHidden = false;
// // }
// //}
//}
if (data.buildNum == obj.buildNum)
{
if (!data.isOn)
{

1
Assets/Scripts/HelpScripts/CloneObjType.cs

@ -480,6 +480,7 @@ public enum CloneObjType
/// </summary>
PowerSupplyCar,
#endregion
SpreadFireFrame,
}
/// <summary>
/// 根据克隆类型获取中文名称。

2
Assets/Scripts/HelpScripts/QuitApplicationManager.cs

@ -37,7 +37,7 @@ public class QuitApplicationManager : MonoSingleton<QuitApplicationManager> {
process.GetMode("assets", ref smart, ref unique, ref validity);
if(smart)
{
SmartController.Instance.Init();
// SmartController.Instance.Init();
}
else if(validity)
{

3
Assets/Scripts/HelpScripts/QuitApplicationManager.cs.meta

@ -1,8 +1,7 @@
fileFormatVersion: 2
guid: db723300d2c5b00469e43ea91e7cd35f
timeCreated: 1551517212
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

12
Assets/Scripts/HelpScripts/TransformHelper.cs

@ -1,3 +1,5 @@
using Newtonsoft.Json;
using System.IO;
using UnityEngine;
/// <summary>
@ -19,7 +21,17 @@ public static class TransformHelper
transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, rotationSpeed);
}
}
public static string LoadJsonFromConfing(string pathname)
{
string json = null;
string path = Path.Combine(Application.streamingAssetsPath, pathname);
if (File.Exists(path))
{
json = File.ReadAllText(path);
}
return JsonConvert.DeserializeObject<string>(json);
}
/// <summary>
/// 查找子物体(递归查找)
/// </summary>

73
Assets/Scripts/SmartX1/ApplicationClose.cs

@ -0,0 +1,73 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
/// <summary>
/// 程序关闭提示处理
/// </summary>
public class ApplicationClose : MonoBehaviour
{
private bool isSure = false;//是否点击确定(退出)按钮
public string SignOutApi = "/api/Account/SignOut";
public bool isSmartX1Exit = false;//是否是检测到没有加密狗而自动退出程序
private void Awake()
{
DontDestroyOnLoad(this);
}
//private void OnApplicationQuit()
//{
// if (!isSmartX1Exit)
// {
// if (!isSure)
// {
// Application.CancelQuit();
// MessageBox.Show("确定退出程序?",
// Sure,
// null
// );
// }
// }
//}
//private void Sure()
//{
// if (!string.IsNullOrEmpty(WebRequestManager.Instance.userName))
// {
// WebRequestManager.Instance.PostJson(WebRequestManager.Instance.httpUrl + SignOutApi, SignOuted, SignOutError);
// }
// else
// {
// isSure = true;
// Application.Quit();
// }
//}
private void SignOuted()
{
isSure = true;
Application.Quit();
}
private void SignOutError(int errorCode, string errorMsg)
{
//MessageBox.Show($"退出程序错误:{errorCode},{errorMsg}", 20);
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

11
Assets/Scripts/SmartX1/ApplicationClose.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 037aa7f639e77b14e8c0fe047fcb62e5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

5
Assets/Scripts/SmartX1/SmartApp.cs.meta

@ -1,8 +1,7 @@
fileFormatVersion: 2
guid: ea8506719ccdade4e9996886ab543d10
timeCreated: 1515718375
licenseType: Pro
guid: 1f37c58fbc18d614fb830dd6caea7b71
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

296
Assets/Scripts/SmartX1/SmartController.cs

@ -1,57 +1,68 @@
using AX.DevelopEngine;
using SmartX1Demo;
using UnityEngine;
using System;
using System.Collections;
using System.Xml;
using System.IO;
using System.Text;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Xml;
using UnityEngine;
using AX.MessageSystem;
using AX.Timer;
using System.Collections;
using SmartX1Demo;
public class SmartController : MonoSingleton<SmartController> {
public class SmartController : MonoBehaviour
{
int[] keyHandles = new int[8];
int[] keyNumber = new int[8];
private int Rtn = 0;
SmartApp smart = new SmartApp();
private Timer timer1_quit, timer2_checkExist;
string appid = "";
private uint uP1 = 0x987F6BCD, uP2 = 0xE193C5B2, uP3 = 0xD507CC28, uP4 = 0x4B125AF6;
private bool IsQuit = false;
private DateTime t1, t2, t11;
string appid = "AXKC";
public void Init()
{
StartInit();
}
// Use this for initialization
void StartInit () {
timer1_quit = new Timer(5.0f);
timer1_quit.AddTimeOutEvent(() =>
{
//Debug.Log("程序退出!");
QuitApplicationManager.Instance.SureQuit();
});
void Start () {
t2 = DateTime.Now;
t1 = DateTime.Now;
DontDestroyOnLoad(GameObject.Find("SmartX1"));
tipStyle = new GUIStyle();
tipStyle.fontSize = 40;
tipStyle.normal.textColor = Color.red;
string original_filepath = Application.dataPath + @"/xml/SmartXProject.xml";
//string encode_filepath = Application.dataPath + @"/xml/enSmartXProject.xml";
//string decode_filepath = Application.dataPath + @"/xml/deSmartXProject.xml";
original_filepath = Application.streamingAssetsPath + @"/xml/SmartXProject.xml";
encode_filepath = Application.streamingAssetsPath + @"/xml/enSmartXProject.xml";
decode_filepath = Application.streamingAssetsPath + @"/xml/deSmartXProject.xml";
ControlXML();
XmlProcess xmlProcess = new XmlProcess(original_filepath);
xmlProcess.SmartControlXML(ref appid);
if (string.IsNullOrEmpty(appid))
{
QuitApplication();
return;
}
//检测加密狗是否存在
FindSmartX1();
}
public string GetAppID(string filepath)
{
if (File.Exists(filepath))
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filepath);
XmlNode root = xmlDoc.SelectSingleNode("SmartX1");
XmlNodeList nodeList = root.ChildNodes;
foreach (XmlElement elem in nodeList)
{
if (elem.Name == "BaseInfo")
{
foreach (XmlElement zq in elem.ChildNodes)
{
if (zq.Name == "AppID")
{
return zq.InnerText;
}
}
}
timer2_checkExist = new Timer(10.0f);
timer2_checkExist.AddTimeOutEvent(CheckExist);
timer2_checkExist.StartTimerRepeat();
}
}
return "";
}
bool FindSmartX1()
{
try
@ -59,8 +70,10 @@ public class SmartController : MonoSingleton<SmartController> {
Rtn = smart.SmartX1Find(appid, keyHandles, keyNumber);
if (Rtn != 0)
{
Debug.Log("SmartX1Find Error,ErrorCode =" + Rtn.ToString());
QuitApplication();
IsQuit = true;
t1 = DateTime.Now;
t2 = DateTime.Now;
t11 = DateTime.Now;
return false;
}
Debug.Log("SmartX1Find Successfully");
@ -70,62 +83,203 @@ public class SmartController : MonoSingleton<SmartController> {
{
Debug.Log(keyHandles[0]);
Debug.Log("异常" + ex.Message);
QuitApplication();
GameObject.Find("Application").GetComponent<ApplicationClose>().isSmartX1Exit = true;
Application.Quit();
return false;
}
}
bool CheckExist()
{
try
{
Rtn = smart.SmartX1CheckExist(keyHandles[0]);
if (Rtn != 0)
{
//Debug.Log("SmartX1 not exist!" + Rtn.ToString());
IsQuit = true;
t1 = DateTime.Now;
t2 = DateTime.Now;
t11 = DateTime.Now;
return false;
}
//Debug.Log("SmartX1Exist!");
return true;
}
catch (Exception ex)
{
//Debug.Log(keyHandles[0]);
//Debug.Log("异常" + ex.Message);
GameObject.Find("Application").GetComponent<ApplicationClose>().isSmartX1Exit = true;
Application.Quit();
return false;
}
}
private GUIStyle tipStyle;
private int timer = 5;
void OnGUI()
{
if (IsQuit)
{
t2 = DateTime.Now;
if(t2-t11>new TimeSpan(0,0,1))
{
if(timer>0)
timer--;
t11 = t2;
}
GUI.Label(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 75, 300, 150), "密钥验证失败,程序将在"+timer+"秒后退出!", tipStyle);
if (t2 - t1 > new TimeSpan(0, 0, 5))
{
//Debug.Log("程序退出!");
GameObject.Find("Application").GetComponent<ApplicationClose>().isSmartX1Exit = true;
Application.Quit();
}
}
}
private void QuitApplication()
// Update is called once per frame
void Update () {
if (IsQuit)
return;
t2 = DateTime.Now;
if (t2 - t1 > new TimeSpan(0, 0, 0, 10, 0))
{
timer1_quit.StartTimer();
t1 = t2;
CheckExist();
}
}
private void ReadStorage()
//xml文件加密解密
void ControlXML()
{
if (File.Exists(original_filepath))//证明这次是第一次运行该程序,获取当前配置文件
{
int read_rtn = 0;
byte[] pbuffer = new byte[4096];
appid = GetAppID(original_filepath);
//StartCoroutine(GenerateEncodeXML());
GenerateEncodeXML1();
}
else
{
if (File.Exists(encode_filepath))
{
fileDcryption(encode_filepath);
if (File.Exists(decode_filepath))
{
appid = GetAppID(decode_filepath);
File.Delete(decode_filepath);
}
}
}
}
int open_rtn = smart.SmartX1Open(keyHandles[0], (int)uP1, (int)uP2, (int)uP3, (int)uP4);
if (open_rtn == 0)//打开成功
IEnumerator GenerateEncodeXML()
{
yield return new WaitForSeconds(1.0f);
fileEncryption(original_filepath);
if (File.Exists(encode_filepath))
{
read_rtn = smart.SmartX1ReadStorage(keyHandles[0], 0, 4096, pbuffer);
string data= Encoding.GetEncoding("gb2312").GetString(pbuffer);
Debug.Log(data);
File.Delete(original_filepath);
}
}
void CheckExist()
void GenerateEncodeXML1()
{
try
fileEncryption(original_filepath);
if (File.Exists(encode_filepath))
{
Rtn = smart.SmartX1CheckExist(keyHandles[0]);
if (Rtn != 0)
File.Delete(original_filepath);
}
}
//加密xml文件
private void Encrypt(XmlDocument doc, string ElementName, SymmetricAlgorithm key)
{
Debug.Log("SmartX1 not exist!" + Rtn.ToString());
QuitApplication();
return;
XmlElement elementEncrypt = doc.GetElementsByTagName(ElementName)[0] as XmlElement;
EncryptedXml eXml = new EncryptedXml();
byte[] encryptElement = eXml.EncryptData(elementEncrypt, key, false);//
EncryptedData edElement = new EncryptedData();
edElement.Type = EncryptedXml.XmlEncElementUrl;
string encryptionMethod = null;
if (key is TripleDES)
{
encryptionMethod = EncryptedXml.XmlEncTripleDESUrl;
}
Debug.Log("SmartX1Exist!");
return;
else if (key is DES)
{
encryptionMethod = EncryptedXml.XmlEncDESUrl;
}
catch (Exception ex)
if (key is Rijndael)
{
Debug.Log(keyHandles[0]);
Debug.Log("异常" + ex.Message);
QuitApplication();
return;
switch (key.KeySize)
{
case 128:
encryptionMethod = EncryptedXml.XmlEncAES128Url;
break;
case 192:
encryptionMethod = EncryptedXml.XmlEncAES192Url;
break;
case 256:
encryptionMethod = EncryptedXml.XmlEncAES256Url;
break;
}
}
void OnGUI()
edElement.EncryptionMethod = new EncryptionMethod(encryptionMethod);
edElement.CipherData.CipherValue = encryptElement;
EncryptedXml.ReplaceElement(elementEncrypt, edElement, false);
}
//XML文件解密
private void Decrypt(XmlDocument doc, SymmetricAlgorithm Alg)
{
XmlElement encryptedElement = doc.GetElementsByTagName("EncryptedData")[0] as XmlElement;
EncryptedData edElement = new EncryptedData();
edElement.LoadXml(encryptedElement);
EncryptedXml exml = new EncryptedXml();
byte[] rgbOutput = exml.DecryptData(edElement, Alg);
exml.ReplaceData(encryptedElement, rgbOutput);
}
string original_filepath = "";
string encode_filepath = "";
string decode_filepath = "";
//举例,对某个XML文件加密
private void fileEncryption(string filename)
{
if (timer1_quit.IsTimering)
RijndaelManaged key = new RijndaelManaged();
//设置密钥:key为32位=数字或字母16个=汉子8个
byte[] byteKey = Encoding.Unicode.GetBytes("1111111111111111");
key.Key = byteKey;
XmlDocument xmldoc = new XmlDocument();
xmldoc.PreserveWhitespace = true;
xmldoc.Load(original_filepath);//想要加密的xml文件
Encrypt(xmldoc, "SmartX1", key);//需要加密的节点
if (key != null)
{
QuitApplicationManager.Instance.SetGuiTip("加密狗验证失败,程序将在 " + timer1_quit.GetRemainingTime() + " 秒后退出!");
key.Clear();
}
xmldoc.Save(encode_filepath);//生成加密后的xml文件
}
// Update is called once per frame
void Update () {
timer1_quit.UpdateTimer();
timer2_checkExist.UpdateTimer();
//举例,对某个xml文件解密
private void fileDcryption(string filename)
{
RijndaelManaged key = new RijndaelManaged();
byte[] byteKey = Encoding.Unicode.GetBytes("1111111111111111");
key.Key = byteKey;
XmlDocument xmldoc = new XmlDocument();
xmldoc.PreserveWhitespace = true;
xmldoc.Load(encode_filepath);//加载要解密的xml文件
Decrypt(xmldoc, key);
if (key != null)
{
key.Clear();
}
xmldoc.Save(decode_filepath);//生成解密后的文件
}
}

5
Assets/Scripts/SmartX1/SmartController.cs.meta

@ -1,8 +1,7 @@
fileFormatVersion: 2
guid: b7b3bd4e725af2649a00a7c9d90fa7ea
timeCreated: 1495250299
licenseType: Pro
guid: f77080dba14a37a4abf47c331b296fb0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

45
Assets/Scripts/SmartX1/SmartX1.prefab

@ -0,0 +1,45 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8989827126564560699
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2279724216670829176}
- component: {fileID: 6226444345072152341}
m_Layer: 0
m_Name: SmartX1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2279724216670829176
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8989827126564560699}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &6226444345072152341
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8989827126564560699}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f77080dba14a37a4abf47c331b296fb0, type: 3}
m_Name:
m_EditorClassIdentifier:

7
Assets/Scripts/SmartX1/SmartX1.prefab.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5b9fb6e0da36afd4aa32e5d0d18f29f9
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

36
Assets/Scripts/SmartX1/SmartX1Api.cs

@ -114,75 +114,75 @@ namespace SmartX1Demo
class SmartX1_X64
{
// Find
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Find(string appID, int[] keyHandles, int[] keyNumber);
//open
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Open(int keyHandle, int uPin1, int uPin2, int uPin3, int uPin4);
//close
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Close(int keyHandle);
//checkExist
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1CheckExist(int keyHandle);
//getUid
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1GetUid(int keyHandle, StringBuilder uid);
//ReadStorage
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1ReadStorage(int keyHandle, int startAddr, int length, byte[] pBuffer);
//WriteStorage
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1WriteStorage(int keyHandle, int startAddr, int length, byte[] pBuffer);
//PageLogin
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1PageLogin(int keyHandle, int pageNo, byte[] password, int length);
//PageLogout
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1PageLogout(int keyHandle, int pageNo);
//ReadPage
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1ReadPage(int keyHandle, int pageNo, int startAddr, ref int length, byte[] pBuffer);
//WritePage
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1WritePage(int keyHandle, int pageNo, int startAddr, int length, byte[] pBuffer);
//ReadMem
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1ReadMem(int keyHandle, int start, int length, byte[] pBuffer);
//WriteMem
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1WriteMem(int keyHandle, int start, int length, byte[] pBuffer);
//encrypt
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1TriDesEncrypt(int keyHandle, int buffSize, byte[] pBuffer);
//desDecrypt
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1TriDesDecrypt(int keyHandle, int buffSize, byte[] pBuffer);
//led
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Led(int keyHandle, int state);
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1PageGetProperty(int keyHandle, int pageNo, int propId, int[] propValue);
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1GetSoftVersion(int keyHandle, int[] version);
public static string TridesEncrypt(string data, string key, Encoding encoding)

5
Assets/Scripts/SmartX1/SmartX1Api.cs.meta

@ -1,8 +1,7 @@
fileFormatVersion: 2
guid: aa527fc755baf7d47ab4c14d9de2a6e8
timeCreated: 1515718375
licenseType: Pro
guid: 30969e5b5d02c2a418f4e239698f27a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

BIN
Assets/Sky/Materials/azure[Sky].mat

Binary file not shown.

2
Assets/StreamingAssets/xml/enSmartXProject.xml

File diff suppressed because one or more lines are too long

7
Assets/StreamingAssets/xml/enSmartXProject.xml.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ebe415df66523c345abd2a1f8c1242d9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

2
Assets/StreamingAssets/xml/enValidity.xml

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#"><EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" /><CipherData><CipherValue>DUFEM8pfzviy8H3Qf8hfuxCnO6FnaUoFi10eV7N6Ed6IlMzRrxzzpkpZWXBUD70+TWT62W4Kf7gGvDTlB5sBNDXZLmf4A+gwMqYhMpg9vWr/ksVYiWaP7JdEcIYXEDyQs5gUB18+cs212Kbz/EjbZbJYE5DD+bNg6IWz152YHyT4E1V8NBTXFAwflN10EiNkiY7PWuqpjft/9UR2qBiS0dT7hGA9ru/V1rQLkQ5LIq6nGQG/7Hmydie8mPW5NkSSa9DNVTpQIPbem/vQt1xkiA==</CipherValue></CipherData></EncryptedData>

7
Assets/StreamingAssets/xml/enValidity.xml.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b3a2e5a3493e7e14099cb324d9075ae5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save