123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Runtime.InteropServices;
-
- //class NT88API
- //{
- ////查找加密锁
- // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- // public static extern int NTFindFirst(string NTCode);
-
- ////查询硬件ID
- // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- // public static extern int NTGetHardwareID(StringBuilder hardwareID);
-
- ////登录加密锁
- // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- // public static extern int NTLogin(string NTpassword);
-
- ////存储区数据读取
- // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- // public static extern int NTRead(int address, int Length, byte[] pData);
-
- ////存储区数据写入
- // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- // public static extern int NTWrite(int address, int Length, byte[] pData);
-
- ////3DES解密
- // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- // public static extern int NT3DESCBCDecrypt(byte[] vi, byte[] pDataBuffer, int Length);
-
- ////3DES加密
- // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- // public static extern int NT3DESCBCEncrypt(byte[] vi, byte[] pDataBuffer, int Length);
-
- ////验证许可证
- // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- // public static extern int NTCheckLicense(int licenseCode);
-
-
-
-
- ////登出加密锁
- // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- // public static extern int NTLogout();
-
- // #region 管理员API
-
-
- ////验证管理员密码
- // [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- // public static extern int NTCheckSuperPin(string superPin);
-
-
- // #endregion
-
-
- //}
-
-
- class NT88API
- {
-
- #region 管理员用法
- //查找所有加密锁,只有找到加密锁才能其他操作,NTFindAll必须第一个执行
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTFindAll(int[] NTHandle, int[] nKeyNum);
-
- /// <summary>
- /// 获取加密锁硬件属性
- /// </summary>
- /// <param name="NTHandle">加密锁handle</param>
- /// <param name="keyMode">加密锁型号</param>
- /// <param name="keyVersion">硬件版本</param>
- /// <param name="e2size">存储区大小</param>
- /// <param name="ramSize">内存区大小</param>
- /// <param name="prouctionTime">生产日期</param>
- /// <returns></returns>
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTGetDevCaps(int NTHandle, int[] keyMode, int[] keyVersion, int[] e2size, int[] ramSize, byte[] prouctionTime);
-
- //获取硬件序列号
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTGetHarddwareID(int NTHandle, string hardwareID);
-
- //检测管理密码
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTCheckSuperPin(int NTHandle, string superin);
-
- //修改加密锁管理密码
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTSetSuperPin(int NTHandle, string newSPin);
-
-
- //修改加密锁登录密码
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTSetUserPin(int NTHandle, string superin, string seed, StringBuilder userPin);
-
- //修改加密锁识别码
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTSetAppName(int NTHandle, StringBuilder NTCode);
-
- //获得加密锁识别码
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTGetAppName(int NTHandle, StringBuilder NTCode);
-
- //读取存储区数据
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTRead(int NTHandle, int address, int length, byte[] pData);
-
- //读写存储区数据
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTWrite(int NTHandle, int address, int length, byte[] pData);
-
- //获取许可证标识及验证码
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTGetLicenseSettings(int NTHandle, byte[] licenseOption, int[] licenseCode, int licOptionNumber);
-
- //设置许可证标识,同时计算出验证码
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTGenLicenseCodes(int NTHandle, byte[] licenseOption, int[] licenseCode, int licOptionNumber);
-
- //验证许可证,输入相应额验证码进行验证
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTCheckLicense(int NTHandle, int licenseCode);
-
- //3DES加密
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NT3DESCBCEncrypt(int NTHandle, byte[] iv, byte[] pDataBuffer, int length);
-
- //3DES设置
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTSet3DESKey(int NTHandle, byte[] key);
-
- //3DES解密
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NT3DESCBCDecrypt(int NTHandle, byte[] iv, byte[] pDataBuffer, int length);
-
-
- //查询硬件ID
- [DllImport("NT88Mgr.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTGetHardwareID(int NTHandle, StringBuilder hardwareID);
-
-
- #endregion
-
-
- /*****************************************/
-
-
- #region 应用层
- //查找加密锁
- [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTFindFirst(string NTCode);
-
- //查询硬件ID
- [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTGetHardwareID(StringBuilder hardwareID);
-
- //登录加密锁
- [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTLogin(string NTpassword);
-
- //存储区数据读取
- [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTRead(int address, int Length, byte[] pData);
-
- //存储区数据写入
- [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTWrite(int address, int Length, byte[] pData);
-
- //3DES解密
- [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NT3DESCBCDecrypt(byte[] vi, byte[] pDataBuffer, int Length);
-
- //3DES加密
- [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NT3DESCBCEncrypt(byte[] vi, byte[] pDataBuffer, int Length);
-
- //验证许可证
- [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
- public static extern int NTCheckLicense(int licenseCode);
-
-
-
-
- //登出加密锁
- [DllImport("NT88.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
- public static extern int NTLogout();
-
-
- #endregion
- }
|