zoukankan      html  css  js  c++  java
  • 赛孚耐(SafeNet)加密狗 C#调用代码

    赛孚耐(SafeNet)加密狗

    购买链接:https://item.jd.com/21653904499.html

    需求:

    加密狗作用:如果未插入加密狗,则程序无法运行。
    我们会给每个客户一个加密狗,希望通过加密狗编号自动对应客户。

    加密狗制作流程:

    1. 安装《超级加密狗工具包》,通过开发商向导安装函数库。
    2. 插入加密狗driver和开发狗master
    3. 使用《外壳加密工具》加密程序
    4. 使用《授权管理工具》授权加密狗有效期

    官方给的API调用文档,太复杂了,看得人晕头转向。整理下备忘。

    using SuperDog;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WinFrmTest
    {
        public partial class Form1 : Form
        {
            // C:Program Files (x86)GemaltoSuperDog2.5VendorCodesFFWWC.hvc
            const string vcode = "xxxx";
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void showInfo(string str)
            {
                textBox1.AppendText(str + System.Environment.NewLine);
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                DogStatus res = DogStatus.StatusOk;
    
                showInfo("获取加密狗信息");
    
                string a1 = ""+
                "<?xml version="1.0" encoding="UTF-8" ?>" +
                "<dogscope/>";
    
                string a2 = "" +
                "<?xml version="1.0" encoding="UTF-8" ?>" +
                "<dogformat root="dog_info">" +
                "    <dog>" +
                "        <attribute name="id" />" +
                "        <attribute name="type" />" +
                "        <feature>" +
                "            <attribute name="id" />" +
                "        </feature>" +
                "    </dog>" +
                "</dogformat>";
    
                string info = "";
                res = Dog.GetInfo(a1, a2, vcode, ref info);
    
                if (res != DogStatus.StatusOk)
                {
                    showInfo("错误:" + res.ToString());
                    return;
                }
    
                showInfo(info);
    
                using (var dog = new Dog(new DogFeature(DogFeature.FromFeature(0).Feature)))
                {
                    showInfo("验证加密狗");
                    res = dog.Login(vcode);
                    if (res != DogStatus.StatusOk)
                    {
                        showInfo("错误:" + res.ToString());
                    }
                    else
                    {
                        showInfo("获取时间");
                        DateTime dt = new DateTime();
                        dog.GetTime(ref dt);
                        showInfo(dt.AddHours(8).ToString());
                    }
                }
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                textBox1.Text = "";
            }
        }
    }
  • 相关阅读:
    基于 HTML5 Canvas 的交互式地铁线路图
    基于HTML5的WebGL实现json和echarts图表展现在同一个界面
    基于HTML5和WebGL的3D网络拓扑结构图
    JavaScript基础:创建对象
    使用ksoap2报java.io.EOFException异常问题解决方法
    Silverlight之我见
    今年的IT大趋势是虚拟现实
    Apache服务器部署ASP.NET网站
    Bootstrap优秀网站:乐窝网
    [转载]C#读取Excel几种方法的体会
  • 原文地址:https://www.cnblogs.com/zjfree/p/14240533.html
Copyright © 2011-2022 走看看