磐石加密狗NT88管理层API

 

直接贴代码了

磐石加密狗NT88管理层API-LMLPHP
  1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Runtime.InteropServices;
5
6 //class NT88API
7 //{
8 ////查找加密锁
9 // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
10 // public static extern int NTFindFirst(string NTCode);
11
12 ////查询硬件ID
13 // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
14 // public static extern int NTGetHardwareID(StringBuilder hardwareID);
15
16 ////登录加密锁
17 // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
18 // public static extern int NTLogin(string NTpassword);
19
20 ////存储区数据读取
21 // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
22 // public static extern int NTRead(int address, int Length, byte[] pData);
23
24 ////存储区数据写入
25 // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
26 // public static extern int NTWrite(int address, int Length, byte[] pData);
27
28 ////3DES解密
29 // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
30 // public static extern int NT3DESCBCDecrypt(byte[] vi, byte[] pDataBuffer, int Length);
31
32 ////3DES加密
33 // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
34 // public static extern int NT3DESCBCEncrypt(byte[] vi, byte[] pDataBuffer, int Length);
35
36 ////验证许可证
37 // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
38 // public static extern int NTCheckLicense(int licenseCode);
39
40
41
42
43 ////登出加密锁
44 // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
45 // public static extern int NTLogout();
46
47 // #region 管理员API
48
49
50 ////验证管理员密码
51 // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
52 // public static extern int NTCheckSuperPin(string superPin);
53
54
55 // #endregion
56
57
58 //}
59
60
61 class NT88API
62 {
63
64 #region 管理员用法
65 //查找所有加密锁,只有找到加密锁才能其他操作,NTFindAll必须第一个执行
66 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
67 public static extern int NTFindAll(int[] NTHandle, int[] nKeyNum);
68
69 /// <summary>
70 /// 获取加密锁硬件属性
71 /// </summary>
72 /// <param name="NTHandle">加密锁handle</param>
73 /// <param name="keyMode">加密锁型号</param>
74 /// <param name="keyVersion">硬件版本</param>
75 /// <param name="e2size">存储区大小</param>
76 /// <param name="ramSize">内存区大小</param>
77 /// <param name="prouctionTime">生产日期</param>
78 /// <returns></returns>
79 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
80 public static extern int NTGetDevCaps(int NTHandle, int[] keyMode, int[] keyVersion, int[] e2size, int[] ramSize, byte[] prouctionTime);
81
82 //获取硬件序列号
83 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
84 public static extern int NTGetHarddwareID(int NTHandle, string hardwareID);
85
86 //检测管理密码
87 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
88 public static extern int NTCheckSuperPin(int NTHandle, string superin);
89
90 //修改加密锁管理密码
91 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
92 public static extern int NTSetSuperPin(int NTHandle, string newSPin);
93
94
95 //修改加密锁登录密码
96 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
97 public static extern int NTSetUserPin(int NTHandle, string superin, string seed, StringBuilder userPin);
98
99 //修改加密锁识别码
100 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
101 public static extern int NTSetAppName(int NTHandle, StringBuilder NTCode);
102
103 //获得加密锁识别码
104 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
105 public static extern int NTGetAppName(int NTHandle, StringBuilder NTCode);
106
107 //读取存储区数据
108 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
109 public static extern int NTRead(int NTHandle, int address, int length, byte[] pData);
110
111 //读写存储区数据
112 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
113 public static extern int NTWrite(int NTHandle, int address, int length, byte[] pData);
114
115 //获取许可证标识及验证码
116 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
117 public static extern int NTGetLicenseSettings(int NTHandle, byte[] licenseOption, int[] licenseCode, int licOptionNumber);
118
119 //设置许可证标识,同时计算出验证码
120 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
121 public static extern int NTGenLicenseCodes(int NTHandle, byte[] licenseOption, int[] licenseCode, int licOptionNumber);
122
123 //验证许可证,输入相应额验证码进行验证
124 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
125 public static extern int NTCheckLicense(int NTHandle, int licenseCode);
126
127 //3DES加密
128 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
129 public static extern int NT3DESCBCEncrypt(int NTHandle, byte[] iv, byte[] pDataBuffer, int length);
130
131 //3DES设置
132 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
133 public static extern int NTSet3DESKey(int NTHandle, byte[] key);
134
135 //3DES解密
136 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
137 public static extern int NT3DESCBCDecrypt(int NTHandle, byte[] iv, byte[] pDataBuffer, int length);
138
139
140 //查询硬件ID
141 [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
142 public static extern int NTGetHardwareID(int NTHandle, StringBuilder hardwareID);
143
144
145 #endregion
146
147
148 /*****************************************/
149
150
151 #region 应用层
152 //查找加密锁
153 [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
154 public static extern int NTFindFirst(string NTCode);
155
156 //查询硬件ID
157 [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
158 public static extern int NTGetHardwareID(StringBuilder hardwareID);
159
160 //登录加密锁
161 [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
162 public static extern int NTLogin(string NTpassword);
163
164 //存储区数据读取
165 [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
166 public static extern int NTRead(int address, int Length, byte[] pData);
167
168 //存储区数据写入
169 [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
170 public static extern int NTWrite(int address, int Length, byte[] pData);
171
172 //3DES解密
173 [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
174 public static extern int NT3DESCBCDecrypt(byte[] vi, byte[] pDataBuffer, int Length);
175
176 //3DES加密
177 [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
178 public static extern int NT3DESCBCEncrypt(byte[] vi, byte[] pDataBuffer, int Length);
179
180 //验证许可证
181 [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
182 public static extern int NTCheckLicense(int licenseCode);
183
184
185
186
187 //登出加密锁
188 [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
189 public static extern int NTLogout();
190
191
192 #endregion
193 }
磐石加密狗NT88管理层API-LMLPHP

以上涉及到的 NT88Mgr.dll 文件可以在磐石公司提供的开发资料中查找 ,也可以点击此处下载附件

04-13 16:04