曹衍涛
5 years ago
21 changed files with 1423 additions and 69 deletions
@ -0,0 +1,213 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
using UnityEditor; |
||||
using UnityEngine.AI; |
||||
using System.IO; |
||||
using System.Text; |
||||
using System; |
||||
|
||||
public class SceneToolFloor |
||||
{ |
||||
//[MenuItem("SceneTool/SetFloorMessage")]//添加FloorMessage脚本绑定楼层信息 |
||||
//public static void SetFloorMessage() |
||||
//{ |
||||
// Transform neiParent = GameObject.Find("shinei").transform.GetChild(0); |
||||
// for (int i = 0; i < neiParent.childCount; i++) |
||||
// { |
||||
// //Debug.Log(neiParent.GetChild(i).name); |
||||
// if (!neiParent.GetChild(i).GetComponent<FloorMessage>()) |
||||
// { |
||||
// neiParent.GetChild(i).gameObject.AddComponent<FloorMessage>(); |
||||
// } |
||||
// FloorMessage msg = neiParent.GetChild(i).GetComponent<FloorMessage>(); |
||||
// msg.targetTrans = GetTarget(neiParent.GetChild(i)); |
||||
// msg.buildNum = neiParent.name; |
||||
// if (!neiParent.GetChild(i).name.ToLower().Contains("m")) |
||||
// { |
||||
// string floornum = neiParent.GetChild(i).name.Substring |
||||
// (neiParent.GetChild(i).name.ToLower().IndexOf("nei") + 3/*, neiParent.GetChild(i).name.Length - 4*/); |
||||
|
||||
// msg.floorNum = int.Parse(floornum); |
||||
// msg.interlayerNum = 0; |
||||
// } |
||||
// else |
||||
// { |
||||
// msg.floorNum = int.Parse(neiParent.GetChild(i).name.Substring |
||||
// (neiParent.GetChild(i).name.ToLower().IndexOf("nei") + 3, neiParent.GetChild(i).name.ToLower().IndexOf("m") |
||||
// - neiParent.GetChild(i).name.ToLower().IndexOf("nei") - 4)); |
||||
// msg.interlayerNum = int.Parse(neiParent.GetChild(i).name.Substring |
||||
// (neiParent.GetChild(i).name.ToLower().IndexOf("m") + 1, neiParent.GetChild(i).name.Length - |
||||
// neiParent.GetChild(i).name.ToLower().IndexOf("m") - 1)); |
||||
// } |
||||
// } |
||||
// Transform waiParent = GameObject.Find("shiwai").transform.GetChild(0); |
||||
// for (int i = 0; i < waiParent.childCount; i++) |
||||
// { |
||||
// //Debug.Log(waiParent.GetChild(i).name); |
||||
// if (!waiParent.GetChild(i).GetComponent<FloorMessage>()) |
||||
// { |
||||
// waiParent.GetChild(i).gameObject.AddComponent<FloorMessage>(); |
||||
// } |
||||
// FloorMessage msg = waiParent.GetChild(i).GetComponent<FloorMessage>(); |
||||
// msg.buildNum = waiParent.name; |
||||
// if (!waiParent.GetChild(i).name.ToLower().Contains("m")) |
||||
// { |
||||
// string floornum = waiParent.GetChild(i).name.Substring |
||||
// (waiParent.GetChild(i).name.ToLower().IndexOf("wai") + 3/*, waiParent.GetChild(i).name.Length - 4*/); |
||||
// msg.floorNum = int.Parse(floornum); |
||||
// msg.interlayerNum = 0; |
||||
// } |
||||
// else |
||||
// { |
||||
// msg.floorNum = int.Parse(waiParent.GetChild(i).name.Substring |
||||
// (waiParent.GetChild(i).name.ToLower().IndexOf("wai") + 4, waiParent.GetChild(i).name.ToLower().IndexOf("m") |
||||
// - waiParent.GetChild(i).name.ToLower().IndexOf("wai") - 4)); |
||||
// msg.interlayerNum = int.Parse(waiParent.GetChild(i).name.Substring |
||||
// (waiParent.GetChild(i).name.ToLower().IndexOf("m") + 1, waiParent.GetChild(i).name.Length - |
||||
// waiParent.GetChild(i).name.ToLower().IndexOf("m") - 1)); |
||||
// } |
||||
// } |
||||
//} |
||||
//static Transform GetTarget(Transform parent) |
||||
//{ |
||||
// for (int i = 0; i < parent.childCount; i++) |
||||
// { |
||||
// if (parent.GetChild(i).name.ToLower().Contains("_floor") |
||||
// || parent.GetChild(i).name.ToLower().Contains("-floor") |
||||
// ) |
||||
// { |
||||
// return parent.GetChild(i); |
||||
// } |
||||
// } |
||||
|
||||
// return parent; |
||||
//} |
||||
//[MenuItem("SceneTool/SetNavLayershinei")]//添加寻路层(选中shinei对象设置,注:扶梯情况特殊没有包含) |
||||
//public static void SetNavLayer() |
||||
//{ |
||||
// Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
||||
// for (int i = 0; i < obj.Length; i++) |
||||
// { |
||||
// if (obj[i].name.ToLower().Contains("_floor") ||//地面 |
||||
// obj[i].name.ToLower().Contains("_floor")) |
||||
// { |
||||
// Debug.Log(obj[i].name); |
||||
// // obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
||||
// // if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
||||
// // { |
||||
// // obj[i].gameObject.AddComponent<MeshCollider>(); |
||||
// // } |
||||
// // if (!obj[i].gameObject.GetComponent<PathFindable>()) |
||||
// // { |
||||
// // obj[i].gameObject.AddComponent<PathFindable>(); |
||||
// // } |
||||
// // if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>()) |
||||
// // { |
||||
// // obj[i].gameObject.AddComponent<CloneGameObjInfo>(); |
||||
// obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType=CloneObjType.staticGameObject; |
||||
// // } |
||||
// // if (!obj[i].gameObject.GetComponent<CloneableEnums>()) |
||||
// // { |
||||
// // obj[i].gameObject.AddComponent<CloneableEnums>(); |
||||
// // } |
||||
// // CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>(); |
||||
// // GameObject CarRoad = GameObject.Find("FloorNei"); |
||||
// // var CloneableEnums = CarRoad.GetComponent<CloneableEnums>(); |
||||
// // enumParent.CloneableTypes = CloneableEnums.CloneableTypes; |
||||
// // if (obj[i].parent.GetComponent<FloorMessage>()) |
||||
// // { |
||||
// // FloorMessage fmg = obj[i].parent.GetComponent<FloorMessage>(); |
||||
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.StaticGameObject; |
||||
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = fmg.buildNum; |
||||
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = fmg.floorNum; |
||||
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = fmg.interlayerNum; |
||||
// // } |
||||
// // if (obj[i].parent.parent.GetComponent<FloorMessage>()) |
||||
// // { |
||||
// // FloorMessage fmg = obj[i].parent.parent.GetComponent<FloorMessage>(); |
||||
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.StaticGameObject; |
||||
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = fmg.buildNum; |
||||
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = fmg.floorNum; |
||||
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = fmg.interlayerNum; |
||||
// // } |
||||
// //} |
||||
// //if (obj[i].name.ToLower().Contains("_wall") ||//墙面 |
||||
// // obj[i].name.ToLower().Contains("_wall")) |
||||
// //{ |
||||
// // obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
||||
// // if (!obj[i].gameObject.GetComponent<NavMeshModifier>()) |
||||
// // { |
||||
// // obj[i].gameObject.AddComponent<NavMeshModifier>(); |
||||
// // } |
||||
// // NavMeshModifier mod = obj[i].gameObject.GetComponent<NavMeshModifier>(); |
||||
// // mod.overrideArea = true; |
||||
// // mod.area = 1; |
||||
// // if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
||||
// // { |
||||
// // obj[i].gameObject.AddComponent<MeshCollider>(); |
||||
// // } |
||||
// //} |
||||
// //if (obj[i].name.ToLower().Contains("lt"))//楼梯 |
||||
// //{ |
||||
// // obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad"); |
||||
// // if (!obj[i].gameObject.GetComponent<MeshCollider>()) |
||||
// // { |
||||
// // obj[i].gameObject.AddComponent<MeshCollider>(); |
||||
// // } |
||||
// // if (!obj[i].gameObject.GetComponent<PathFindable>()) |
||||
// // { |
||||
// // obj[i].gameObject.AddComponent<PathFindable>(); |
||||
// // } |
||||
// } |
||||
// } |
||||
//} |
||||
//[MenuItem("SceneTool/GetNavLayerCarRoad")] |
||||
//public static void GetNavLayerCarRoad() |
||||
//{ |
||||
// Transform[] obj = Selection.GetTransforms(SelectionMode.Deep); |
||||
// { |
||||
// for (int i = 0; i < obj.Length; i++) |
||||
// { |
||||
// if (obj[i].gameObject.layer == LayerMask.NameToLayer("CarRoad")) |
||||
// { |
||||
// // if (!obj[i].gameObject.GetComponent<NavMeshModifier>()) |
||||
// { |
||||
// Debug.Log(obj[i].name); |
||||
// } |
||||
// } |
||||
// } |
||||
// } |
||||
//} |
||||
//[MenuItem("SceneTool/ReadCloneTypes")] |
||||
//static void ReadCloneTypes() |
||||
//{ |
||||
// string path = Application.dataPath + "/Floors.txt"; |
||||
// string str = File.ReadAllText(path, Encoding.UTF8); |
||||
// string[] EnumStrList = str.Split(','); |
||||
// //List<CloneObjType> EnmuList = new List<CloneObjType>(); |
||||
// //foreach (var item in EnumStrList) |
||||
// //{ |
||||
// // if (!string.IsNullOrEmpty(item)) |
||||
// // { |
||||
// // CloneObjType type = (CloneObjType)Enum.Parse(typeof(CloneObjType), item); |
||||
// // EnmuList.Add(type); |
||||
// // } |
||||
// //} |
||||
// //GameObject CarRoad = GameObject.Find("FloorNei"); |
||||
// //if (!CarRoad.GetComponent<CloneableEnums>()) |
||||
// //{ |
||||
// // CarRoad.AddComponent<CloneableEnums>(); |
||||
// //} |
||||
// //var CloneableEnums = CarRoad.GetComponent<CloneableEnums>(); |
||||
// //CloneableEnums.CloneableTypes = EnmuList; |
||||
//} |
||||
//[MenuItem("SceneTool/AddColider")] |
||||
//static void AddColider() |
||||
//{ |
||||
// Transform[] obj = Selection.GetTransforms(SelectionMode.Unfiltered); |
||||
// { |
||||
// Debug.Log(obj[0].name); |
||||
// } |
||||
//} |
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 64783b6d3a93095469a2c37618e659f0 |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
Binary file not shown.
@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 5ca7162f4ce085947800aa96363b3551 |
||||
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: |
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 42d3b95abd582bc42afe2646828af763 |
||||
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 |
||||
- first: |
||||
Windows Store Apps: WindowsStoreApps |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: AnyCPU |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 0965f84e7f9c4bb4a9ed42f8334139ed |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
Binary file not shown.
@ -0,0 +1,136 @@
|
||||
fileFormatVersion: 2 |
||||
guid: b4224153725ef6e468efeab33ad7e553 |
||||
timeCreated: 1515718354 |
||||
licenseType: Pro |
||||
PluginImporter: |
||||
serializedVersion: 2 |
||||
iconMap: {} |
||||
executionOrder: {} |
||||
isPreloaded: 0 |
||||
isOverridable: 0 |
||||
platformData: |
||||
data: |
||||
first: |
||||
'': Any |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
Exclude Android: 0 |
||||
Exclude Editor: 1 |
||||
Exclude Linux: 1 |
||||
Exclude Linux64: 1 |
||||
Exclude LinuxUniversal: 1 |
||||
Exclude OSXIntel: 1 |
||||
Exclude OSXIntel64: 1 |
||||
Exclude OSXUniversal: 1 |
||||
Exclude WebGL: 0 |
||||
Exclude Win: 1 |
||||
Exclude Win64: 1 |
||||
data: |
||||
first: |
||||
'': Editor |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: AnyCPU |
||||
OS: Windows |
||||
data: |
||||
first: |
||||
Android: Android |
||||
second: |
||||
enabled: 1 |
||||
settings: |
||||
CPU: ARMv7 |
||||
data: |
||||
first: |
||||
Any: |
||||
second: |
||||
enabled: 1 |
||||
settings: {} |
||||
data: |
||||
first: |
||||
Editor: Editor |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: x86_64 |
||||
DefaultValueInitialized: true |
||||
data: |
||||
first: |
||||
Facebook: Win |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: AnyCPU |
||||
data: |
||||
first: |
||||
Facebook: Win64 |
||||
second: |
||||
enabled: 1 |
||||
settings: |
||||
CPU: AnyCPU |
||||
data: |
||||
first: |
||||
Standalone: Linux |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: None |
||||
data: |
||||
first: |
||||
Standalone: Linux64 |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: x86_64 |
||||
data: |
||||
first: |
||||
Standalone: LinuxUniversal |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: None |
||||
data: |
||||
first: |
||||
Standalone: OSXIntel |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: None |
||||
data: |
||||
first: |
||||
Standalone: OSXIntel64 |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: AnyCPU |
||||
data: |
||||
first: |
||||
Standalone: OSXUniversal |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: None |
||||
data: |
||||
first: |
||||
Standalone: Win |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: AnyCPU |
||||
data: |
||||
first: |
||||
Standalone: Win64 |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: AnyCPU |
||||
data: |
||||
first: |
||||
WebGL: WebGL |
||||
second: |
||||
enabled: 1 |
||||
settings: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: eae1f933c7e75804cb6fe9ead9b3405b |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,275 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
|
||||
namespace SmartX1Demo |
||||
{ |
||||
public class SmartApp |
||||
{ |
||||
bool _is64ibt = false; |
||||
public SmartApp() |
||||
{ |
||||
if (IntPtr.Size == 4) |
||||
_is64ibt = true; |
||||
} |
||||
public int SmartX1Find(string appID, int[] keyHandles, int[] keyNumber) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1Find(appID, keyHandles, keyNumber); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1Find(appID, keyHandles, keyNumber); |
||||
} |
||||
} |
||||
|
||||
//open |
||||
|
||||
public int SmartX1Open(int keyHandle, int uPin1, int uPin2, int uPin3, int uPin4) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1Open(keyHandle, uPin1, uPin2, uPin3, uPin4); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1Open(keyHandle, uPin1, uPin2, uPin3, uPin4); |
||||
} |
||||
} |
||||
//close |
||||
|
||||
|
||||
public int SmartX1Close(int keyHandle) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1Close(keyHandle); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1Close(keyHandle); |
||||
} |
||||
} |
||||
//checkExist |
||||
|
||||
|
||||
public int SmartX1CheckExist(int keyHandle) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1CheckExist(keyHandle); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1CheckExist(keyHandle); |
||||
} |
||||
} |
||||
//getUid |
||||
|
||||
public int SmartX1GetUid(int keyHandle, StringBuilder uid) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1GetUid(keyHandle, uid); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1GetUid(keyHandle, uid); |
||||
} |
||||
} |
||||
//ReadStorage |
||||
|
||||
public int SmartX1ReadStorage(int keyHandle, int startAddr, int length, byte[] pBuffer) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1ReadStorage(keyHandle, startAddr, length, pBuffer); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1ReadStorage(keyHandle, startAddr, length, pBuffer); |
||||
} |
||||
} |
||||
//WriteStorage |
||||
|
||||
public int SmartX1WriteStorage(int keyHandle, int startAddr, int length, byte[] pBuffer) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1WriteStorage(keyHandle, startAddr, length, pBuffer); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1WriteStorage(keyHandle, startAddr, length, pBuffer); |
||||
} |
||||
} |
||||
//PageLogin |
||||
|
||||
public int SmartX1PageLogin(int keyHandle, int pageNo, byte[] password, int length) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1PageLogin(keyHandle, pageNo, password, length); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1PageLogin(keyHandle, pageNo, password, length); |
||||
} |
||||
} |
||||
//PageLogout |
||||
|
||||
public int SmartX1PageLogout(int keyHandle, int pageNo) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1PageLogout(keyHandle, pageNo); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1PageLogout(keyHandle, pageNo); |
||||
} |
||||
} |
||||
//ReadPage |
||||
|
||||
public int SmartX1ReadPage(int keyHandle, int pageNo, int startAddr, ref int length, byte[] pBuffer) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1ReadPage(keyHandle, pageNo, startAddr, ref length, pBuffer); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1ReadPage(keyHandle, pageNo, startAddr, ref length, pBuffer); |
||||
} |
||||
} |
||||
//WritePage |
||||
|
||||
public int SmartX1WritePage(int keyHandle, int pageNo, int startAddr, int length, byte[] pBuffer) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1WritePage(keyHandle, pageNo, startAddr, length, pBuffer); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1WritePage(keyHandle, pageNo, startAddr, length, pBuffer); |
||||
} |
||||
} |
||||
//ReadMem |
||||
|
||||
public int SmartX1ReadMem(int keyHandle, int start, int length, byte[] pBuffer) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1ReadMem(keyHandle, start, length, pBuffer); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1ReadMem(keyHandle, start, length, pBuffer); |
||||
} |
||||
} |
||||
//WriteMem |
||||
|
||||
public int SmartX1WriteMem(int keyHandle, int start, int length, byte[] pBuffer) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1WriteMem( keyHandle, start, length, pBuffer); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1WriteMem(keyHandle, start, length, pBuffer); |
||||
} |
||||
} |
||||
//encrypt |
||||
|
||||
public int SmartX1TriDesEncrypt(int keyHandle, int buffSize, byte[] pBuffer) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1TriDesEncrypt(keyHandle, buffSize, pBuffer); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1TriDesEncrypt(keyHandle, buffSize, pBuffer); |
||||
} |
||||
} |
||||
//desDecrypt |
||||
|
||||
public int SmartX1TriDesDecrypt(int keyHandle, int buffSize, byte[] pBuffer) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1TriDesDecrypt(keyHandle, buffSize, pBuffer); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1TriDesDecrypt(keyHandle, buffSize, pBuffer); |
||||
} |
||||
} |
||||
//led |
||||
|
||||
public int SmartX1Led(int keyHandle, int state) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1Led(keyHandle, state); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1Led(keyHandle, state); |
||||
} |
||||
} |
||||
|
||||
public int SmartX1PageGetProperty(int keyHandle, int pageNo, int propId, int[] propValue) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1PageGetProperty(keyHandle, pageNo, propId, propValue); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1PageGetProperty(keyHandle, pageNo, propId, propValue); |
||||
} |
||||
} |
||||
public int SmartX1GetSoftVersion(int keyHandle, int[] version) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.SmartX1GetSoftVersion(keyHandle, version); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.SmartX1GetSoftVersion(keyHandle, version); |
||||
} |
||||
} |
||||
|
||||
public string TridesEncrypt(string data, string key, Encoding encoding) |
||||
{ |
||||
|
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.TridesEncrypt(data, key, encoding); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.TridesEncrypt(data, key, encoding); |
||||
} |
||||
} |
||||
|
||||
public string TridesDecEncrypt(byte[] data, string key, Encoding encoding) |
||||
{ |
||||
if (_is64ibt) |
||||
{ |
||||
return SmartX1_X86.TridesDecEncrypt(data, key, encoding); |
||||
} |
||||
else |
||||
{ |
||||
return SmartX1_X64.TridesDecEncrypt(data, key, encoding); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 0dd22a80b53a7c942a93255e8d8ecc3a |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,280 @@
|
||||
using UnityEngine; |
||||
using System; |
||||
using System.Xml; |
||||
using System.IO; |
||||
using System.Text; |
||||
|
||||
using System.Security.Cryptography; |
||||
using System.Security.Cryptography.Xml; |
||||
using System.Collections; |
||||
|
||||
using SmartX1Demo; |
||||
|
||||
public class SmartController : MonoBehaviour |
||||
{ |
||||
int[] keyHandles = new int[8]; |
||||
int[] keyNumber = new int[8]; |
||||
private int Rtn = 0; |
||||
SmartApp smart = new SmartApp(); |
||||
private bool IsQuit = false; |
||||
|
||||
private DateTime t1, t2, t11; |
||||
void Start() |
||||
{ |
||||
t2 = DateTime.Now; |
||||
t1 = DateTime.Now; |
||||
DontDestroyOnLoad(GameObject.Find("SmartX1")); |
||||
|
||||
tipStyle = new GUIStyle(); |
||||
tipStyle.fontSize = 40; |
||||
tipStyle.normal.textColor = Color.red; |
||||
|
||||
original_filepath = Application.streamingAssetsPath + @"/xml/SmartXProject.xml"; |
||||
encode_filepath = Application.streamingAssetsPath + @"/xml/enSmartXProject.xml"; |
||||
decode_filepath = Application.streamingAssetsPath + @"/xml/deSmartXProject.xml"; |
||||
original_filepath2 = Application.streamingAssetsPath + @"/xml/SmartXProject2.xml"; |
||||
encode_filepath2 = Application.streamingAssetsPath + @"/xml/enSmartXProject2.xml"; |
||||
decode_filepath2 = Application.streamingAssetsPath + @"/xml/deSmartXProject2.xml"; |
||||
|
||||
appid = ControlXML(original_filepath, encode_filepath, decode_filepath); |
||||
appid2 = ControlXML(original_filepath2, encode_filepath2, decode_filepath2); |
||||
//appid = GetAppID(original_filepath); |
||||
|
||||
//检测加密狗是否存在 |
||||
FindSmartX1(); |
||||
} |
||||
string appid = "AXKC"; |
||||
string appid2 = "YuAnguanli"; |
||||
public string GetAppID(string filepath) |
||||
{ |
||||
//filepath = Application.dataPath + @"/xml/SmartXProject.xml"; |
||||
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; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
||||
return ""; |
||||
} |
||||
void FindSmartX1() |
||||
{ |
||||
try |
||||
{ |
||||
Rtn = smart.SmartX1Find(appid, keyHandles, keyNumber); |
||||
if (Rtn == 0) |
||||
{ |
||||
return; |
||||
} |
||||
|
||||
Rtn = smart.SmartX1Find(appid2, keyHandles, keyNumber); |
||||
if (Rtn == 0) |
||||
{ |
||||
return; |
||||
} |
||||
IsQuit = true; |
||||
t1 = DateTime.Now; |
||||
t2 = DateTime.Now; |
||||
t11 = DateTime.Now; |
||||
|
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
Debug.Log("异常" + ex.Message); |
||||
Application.Quit(); |
||||
} |
||||
} |
||||
void CheckExist() |
||||
{ |
||||
try |
||||
{ |
||||
Rtn = smart.SmartX1CheckExist(keyHandles[0]); |
||||
if (Rtn != 0) |
||||
{ |
||||
IsQuit = true; |
||||
} |
||||
|
||||
if (IsQuit) |
||||
{ |
||||
t1 = DateTime.Now; |
||||
t2 = DateTime.Now; |
||||
t11 = DateTime.Now; |
||||
} |
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
Debug.Log("异常" + ex.Message); |
||||
Application.Quit(); |
||||
} |
||||
} |
||||
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("程序退出!"); |
||||
Application.Quit(); |
||||
} |
||||
} |
||||
} |
||||
// Update is called once per frame |
||||
void Update() |
||||
{ |
||||
if (IsQuit) |
||||
return; |
||||
t2 = DateTime.Now; |
||||
if (t2 - t1 > new TimeSpan(0, 0, 0, 10, 0)) |
||||
{ |
||||
t1 = t2; |
||||
CheckExist(); |
||||
} |
||||
} |
||||
|
||||
|
||||
//xml文件加密解密 |
||||
|
||||
string ControlXML(string originalFile, string encodeFile, string decodeFile) |
||||
{ |
||||
var id = ""; |
||||
if (File.Exists(originalFile))//证明这次是第一次运行该程序,获取当前配置文件 |
||||
{ |
||||
id = GetAppID(originalFile); |
||||
fileEncryption(originalFile, encodeFile); |
||||
if (File.Exists(encodeFile)) |
||||
{ |
||||
File.Delete(originalFile); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
if (File.Exists(encodeFile)) |
||||
{ |
||||
fileDcryption(encodeFile, decodeFile); |
||||
if (File.Exists(decodeFile)) |
||||
{ |
||||
id = GetAppID(decodeFile); |
||||
File.Delete(decodeFile); |
||||
} |
||||
} |
||||
} |
||||
//Debug.Log("--------->" + id); |
||||
return id; |
||||
} |
||||
|
||||
//加密xml文件 |
||||
private void Encrypt(XmlDocument doc, string ElementName, SymmetricAlgorithm key) |
||||
{ |
||||
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; |
||||
} |
||||
else if (key is DES) |
||||
{ |
||||
encryptionMethod = EncryptedXml.XmlEncDESUrl; |
||||
} |
||||
|
||||
if (key is Rijndael) |
||||
{ |
||||
switch (key.KeySize) |
||||
{ |
||||
case 128: |
||||
encryptionMethod = EncryptedXml.XmlEncAES128Url; |
||||
break; |
||||
case 192: |
||||
encryptionMethod = EncryptedXml.XmlEncAES192Url; |
||||
break; |
||||
case 256: |
||||
encryptionMethod = EncryptedXml.XmlEncAES256Url; |
||||
break; |
||||
} |
||||
} |
||||
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 = ""; |
||||
|
||||
string original_filepath2 = ""; |
||||
string encode_filepath2 = ""; |
||||
string decode_filepath2 = ""; |
||||
//举例,对某个XML文件加密 |
||||
private void fileEncryption(string originalFile, string encodeFile) |
||||
{ |
||||
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(originalFile);//想要加密的xml文件 |
||||
Encrypt(xmldoc, "SmartX1", key);//需要加密的节点 |
||||
if (key != null) |
||||
{ |
||||
key.Clear(); |
||||
} |
||||
xmldoc.Save(encodeFile);//生成加密后的xml文件 |
||||
} |
||||
//举例,对某个xml文件解密 |
||||
private void fileDcryption(string encodeFile, string decodeFile) |
||||
{ |
||||
RijndaelManaged key = new RijndaelManaged(); |
||||
byte[] byteKey = Encoding.Unicode.GetBytes("1111111111111111"); |
||||
key.Key = byteKey; |
||||
XmlDocument xmldoc = new XmlDocument(); |
||||
xmldoc.PreserveWhitespace = true; |
||||
xmldoc.Load(encodeFile);//加载要解密的xml文件 |
||||
Decrypt(xmldoc, key); |
||||
if (key != null) |
||||
{ |
||||
key.Clear(); |
||||
} |
||||
xmldoc.Save(decodeFile);//生成解密后的文件 |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: ae7ba88dc2eb0ac428673f57e7adae5e |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,214 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Runtime.InteropServices; |
||||
using System.Security.Cryptography; |
||||
|
||||
namespace SmartX1Demo |
||||
{ |
||||
public class SmartX1_X86 |
||||
{ |
||||
|
||||
//注意不要添加.dll后缀 |
||||
// Find |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1Find(string appID, int[] keyHandles, int[] keyNumber); |
||||
|
||||
//open |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1Open(int keyHandle, int uPin1, int uPin2, int uPin3, int uPin4); |
||||
//close |
||||
|
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1Close(int keyHandle); |
||||
|
||||
//checkExist |
||||
|
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1CheckExist(int keyHandle); |
||||
|
||||
//getUid |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1GetUid(int keyHandle, StringBuilder uid); |
||||
|
||||
//ReadStorage |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1ReadStorage(int keyHandle, int startAddr, int length, byte[] pBuffer); |
||||
|
||||
//WriteStorage |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1WriteStorage(int keyHandle, int startAddr, int length, byte[] pBuffer); |
||||
|
||||
//PageLogin |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1PageLogin(int keyHandle, int pageNo, byte[] password, int length); |
||||
|
||||
//PageLogout |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1PageLogout(int keyHandle, int pageNo); |
||||
|
||||
//ReadPage |
||||
[DllImport("SmartX1App", 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", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1WritePage(int keyHandle, int pageNo, int startAddr, int length, byte[] pBuffer); |
||||
|
||||
//ReadMem |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1ReadMem(int keyHandle, int start, int length, byte[] pBuffer); |
||||
|
||||
//WriteMem |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1WriteMem(int keyHandle, int start, int length, byte[] pBuffer); |
||||
|
||||
//encrypt |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1TriDesEncrypt(int keyHandle, int buffSize, byte[] pBuffer); |
||||
|
||||
//desDecrypt |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1TriDesDecrypt(int keyHandle, int buffSize, byte[] pBuffer); |
||||
|
||||
//led |
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1Led(int keyHandle, int state); |
||||
|
||||
|
||||
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1PageGetProperty(int keyHandle, int pageNo, int propId, int[] propValue); |
||||
|
||||
[DllImport("SmartX1App", 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) |
||||
{ |
||||
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider(); |
||||
des.Key = Encoding.Default.GetBytes(key); |
||||
des.Mode = CipherMode.ECB; |
||||
|
||||
des.Padding = PaddingMode.PKCS7; |
||||
|
||||
ICryptoTransform DesEncrypt = des.CreateEncryptor(); |
||||
byte[] dataBytes = encoding.GetBytes(data); |
||||
byte[] outPut = DesEncrypt.TransformFinalBlock(dataBytes, 0, dataBytes.Length); |
||||
return Convert.ToBase64String(outPut); |
||||
|
||||
} |
||||
|
||||
public static string TridesDecEncrypt(byte[] data, string key, Encoding encoding) |
||||
{ |
||||
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider(); |
||||
des.Key = Encoding.Default.GetBytes(key); |
||||
des.Padding = PaddingMode.PKCS7; |
||||
des.Mode = CipherMode.ECB; |
||||
ICryptoTransform DesDecEncrypt = des.CreateDecryptor(); |
||||
byte[] outValue = DesDecEncrypt.TransformFinalBlock(data, 0, data.Length); |
||||
return encoding.GetString(outValue); |
||||
} |
||||
} |
||||
|
||||
|
||||
class SmartX1_X64 |
||||
{ |
||||
// Find |
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1Find(string appID, int[] keyHandles, int[] keyNumber); |
||||
|
||||
//open |
||||
[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("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1Close(int keyHandle); |
||||
|
||||
//checkExist |
||||
|
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1CheckExist(int keyHandle); |
||||
|
||||
//getUid |
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1GetUid(int keyHandle, StringBuilder uid); |
||||
|
||||
//ReadStorage |
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1ReadStorage(int keyHandle, int startAddr, int length, byte[] pBuffer); |
||||
|
||||
//WriteStorage |
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1WriteStorage(int keyHandle, int startAddr, int length, byte[] pBuffer); |
||||
|
||||
//PageLogin |
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1PageLogin(int keyHandle, int pageNo, byte[] password, int length); |
||||
|
||||
//PageLogout |
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1PageLogout(int keyHandle, int pageNo); |
||||
|
||||
//ReadPage |
||||
[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("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1WritePage(int keyHandle, int pageNo, int startAddr, int length, byte[] pBuffer); |
||||
|
||||
//ReadMem |
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1ReadMem(int keyHandle, int start, int length, byte[] pBuffer); |
||||
|
||||
//WriteMem |
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1WriteMem(int keyHandle, int start, int length, byte[] pBuffer); |
||||
|
||||
//encrypt |
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1TriDesEncrypt(int keyHandle, int buffSize, byte[] pBuffer); |
||||
|
||||
//desDecrypt |
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1TriDesDecrypt(int keyHandle, int buffSize, byte[] pBuffer); |
||||
|
||||
//led |
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1Led(int keyHandle, int state); |
||||
|
||||
|
||||
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
||||
public static extern int SmartX1PageGetProperty(int keyHandle, int pageNo, int propId, int[] propValue); |
||||
|
||||
[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) |
||||
{ |
||||
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider(); |
||||
des.Key = Encoding.Default.GetBytes(key); |
||||
des.Mode = CipherMode.ECB; |
||||
|
||||
des.Padding = PaddingMode.PKCS7; |
||||
|
||||
ICryptoTransform DesEncrypt = des.CreateEncryptor(); |
||||
byte[] dataBytes = encoding.GetBytes(data); |
||||
byte[] outPut = DesEncrypt.TransformFinalBlock(dataBytes, 0, dataBytes.Length); |
||||
return Convert.ToBase64String(outPut); |
||||
|
||||
} |
||||
|
||||
public static string TridesDecEncrypt(byte[] data, string key, Encoding encoding) |
||||
{ |
||||
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider(); |
||||
des.Key = Encoding.Default.GetBytes(key); |
||||
des.Padding = PaddingMode.PKCS7; |
||||
des.Mode = CipherMode.ECB; |
||||
ICryptoTransform DesDecEncrypt = des.CreateDecryptor(); |
||||
byte[] outValue = DesDecEncrypt.TransformFinalBlock(data, 0, data.Length); |
||||
return encoding.GetString(outValue); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 29d71005b2314cb49b256b33cfcd8fbd |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 871c53a1373720349bb4841eeb3c6fc4 |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue