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 = "";
            }
        }
    }
  • 相关阅读:
    XP下关于快速切换用户功能的相关编程
    CRC原理及其逆向分析方法
    爱的十个秘密4.给予的力量
    爱的十个秘密1.序幕
    隐式链接无.LIB动态链接库
    电影图标黑客帝国(The Matrix)
    手机图标
    圣斗士图标:十二星座黄金圣衣
    MAC风格图标
    GB码与BIG5
  • 原文地址:https://www.cnblogs.com/zjfree/p/14240533.html
Copyright © 2011-2022 走看看