• 加密狗的管理层API(C#代码)


    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
     }
  • 相关阅读:
    android布局
    Windows7 32/64位系统搭建Cocos2d-x及Android交叉编译环境
    第12章 文件管理
    第十章 多处理器和实时调度
    C语言实现多级反馈队列调度算法
    C++实现操作系统调度算法(FSFS,SJF,RR,多级反馈队列算法)
    多级反馈队列调度算法
    第九章 单处理器调度
    第六章 并发:死锁与饥饿
    第七章 内存管理
  • 原文地址:https://www.cnblogs.com/accumulater/p/6255228.html
Copyright © 2020-2023  润新知