DELL
2025-04-28 e6eb7fb0af366e370f125668d62e89eb0004f517
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package com.ueky;
 
 
 
import com.softkey.jsyunew3;
 
/**
 * This class can take a variable number of parameters on the command
 * line. Program execution begins with the main() method. The class
 * constructor is not invoked unless an object of type 'Class1'
 * created in the main() method.
 */
public class test
{
    /**
     * The main entry point for the application. 
     *
     * @param args Array of parameters passed to the application
     * via the command line.
     */
    public static void main (String[] args)
    {
        // TODO: Add initialization code here
        //´òÓ¡Jsyunew3_64.dllÒÔ¼°Jsyunew3.dll´æ·Å·¾¶
        //System.out.println(System.getProperty("java.library.path"));
        com.softkey.jsyunew3 mD8=new  com.softkey.jsyunew3();
        String DevicePath;
        //³õ²½²éÕÒ¼ÓÃܹ·
        {
         //ÒªÕÒµ½¶ÔÓ¦·¢ÐеÄËø£¬ÇëʹÓÃFindD8º¯Êý£¬ÔÚÉú³ÉµÄRunFunc´úÂëÖоÍÓÐÕâ¸ö´úÂ룬
 
            //Õâ¸öÓÃÓÚÅжÏϵͳÖÐÊÇ·ñ´æÔÚ×Å2°ÑÒÔÉϵÄÈÎÒâ¼ÓÃÜËø¡£²¢²»Ö¸¶¨·¢ÐеÄËø
            DevicePath = mD8.FindPort(1);
            if(mD8.get_LastError()==0)
            {
                System.out.println("ϵͳÖдæÔÚ¶à°Ñ¼ÓÃÜËø£¬Ö»¶ÔĬÈϵÄËø½øÐвÙ×÷¡£");
            }
            
            //Õâ¸öÓÃÓÚÅжÏϵͳÖÐÊÇ·ñ´æÔÚ׿ÓÃÜËø¡£²»ÐèÒªÊÇÖ¸¶¨µÄ¼ÓÃÜËø,
            DevicePath = mD8.FindPort(0);
            if(mD8.get_LastError()!=0)
            {
                System.out.println("δÕÒµ½¼ÓÃÜËø,Çë²åÈë¼ÓÃÜËøºó£¬ÔÙ½øÐвÙ×÷¡£");
                System.exit(-1);
            }
        }
        //»ñÈ¡ËøµÄоƬΨһID
        {
            //¼ÓÃܹ·Ð¾Æ¬Î¨Ò»ID£¬Îª32¸ö×Ö·û³¤¶È
            String ChipId=mD8.GetChipID(DevicePath);
            if (mD8.get_LastError() != 0) { System.out.println("·µ»Ø¼ÓÃÜËøµÄоƬΨһIDʱ³öÏÖ´íÎó"); return; }
            System.out.println("Òѳɹ¦·µ»Ø¼ÓÃÜËøµÄоƬΨһID£º" + ChipId);
        }
        
        //»ñÈ¡ËøµÄоƬPublicX
        {
            //¼ÓÃܹ·Ð¾Æ¬Î¨Ò»ID£¬Îª32¸ö×Ö·û³¤¶È
            String PubKeyX=mD8.GetPubKeyX(DevicePath);
            if (mD8.get_LastError() != 0) { System.out.println("·µ»Ø¼ÓÃÜËøµÄPublicXʱ³öÏÖ´íÎó"); return; }
            System.out.println("Òѳɹ¦·µ»Ø¼ÓÃÜËøµÄPublicX£º" + PubKeyX);
        }
        
        //»ñÈ¡ËøµÄоƬPublicY
        {
            //¼ÓÃܹ·Ð¾Æ¬Î¨Ò»ID£¬Îª32¸ö×Ö·û³¤¶È
            String PublicY=mD8.GetPubKeyY(DevicePath);
            if (mD8.get_LastError() != 0) { System.out.println("·µ»Ø¼ÓÃÜËøµÄPublicYʱ³öÏÖ´íÎó"); return; }
            System.out.println("Òѳɹ¦·µ»Ø¼ÓÃÜËøµÄPublicY£º" + PublicY);
        }
        
        //»ñÈ¡ËøµÄоƬUserName
        {
            //¼ÓÃܹ·Ð¾Æ¬Î¨Ò»ID£¬Îª32¸ö×Ö·û³¤¶È
            String UserName=mD8.GetSm2UserName(DevicePath);
            if (mD8.get_LastError() != 0) { System.out.println("·µ»Ø¼ÓÃÜËøµÄUserNameʱ³öÏÖ´íÎó"); return; }
            System.out.println("Òѳɹ¦·µ»Ø¼ÓÃÜËøµÄUserName£º" + UserName);
        }
        
        {
            
            //¿ªÊ¼Éú³É˽Կ¶Ô,¸üÐÂ³ÉÆ½Ì¨Ê¹ÓõÄʱÓõ½
            int code =mD8.StarGenKeyPair(DevicePath);
            if (mD8.get_LastError() != 0) { System.out.println("·µ»Ø¼ÓÃÜËøµÄcodeʱ³öÏÖ´íÎó"); return; }
            System.out.println("Òѳɹ¦·µ»Ø¼ÓÃÜËøµÄcode£º" + code);
        }
        
        //»ñÈ¡ËøµÄоƬPriKey
        {
            //¼ÓÃܹ·Ð¾Æ¬Î¨Ò»ID£¬Îª32¸ö×Ö·û³¤¶È
            String PriKey=mD8.get_GenPriKey();
            if (mD8.get_LastError() != 0) { System.out.println("·µ»Ø¼ÓÃÜËøµÄPriKeyʱ³öÏÖ´íÎó"); return; }
            System.out.println("Òѳɹ¦·µ»Ø¼ÓÃÜËøµÄPriKey£º" + PriKey);
        }
        
        
        //ÓÃÓÚ·µ»Ø¼ÓÃܹ·µÄ°æ±¾ºÅ
        {
            int ver = mD8.GetVersion(DevicePath);
            if(mD8.get_LastError() !=0){ System.out.println("·µ»Ø¼ÓÃÜËøµÄ°æ±¾ºÅʱ´íÎó");return ;}
            System.out.println("Òѳɹ¦·µ»Ø¼ÓÃÜËøµÄ°æ±¾ºÅ:"+Integer.toString(ver));
        }
         //ÓÃÓÚ·µ»Ø¼ÓÃܹ·µÄ¹¦Äܰ汾ºÅ
        {
            int FunVer = mD8.GetFuncVer(DevicePath);
            if(mD8.get_LastError() !=0){ System.out.println("·µ»Ø¼ÓÃÜËøµÄ¹¦Äܰ汾ºÅʱ´íÎó");return ;}
            System.out.println("Òѳɹ¦·µ»Ø¼ÓÃÜËøµÄ¹¦Äܰ汾ºÅ:"+Integer.toString(FunVer));
        }
        ////ÔËÐÐ×Ô¶¨Ò庯Êý 
        int ret = new CRunFunc().RunFunc();
        if (ret != 0)
        {
            System.out.println("ÔËÐÐ×Ô¶¨Ò庯Êýʧ°Ü£¬´íÎóÂëÊÇ£º"+Integer.toString(ret)); 
            return;
        }
        System.out.println("ÔËÐÐ×Ô¶¨Ò庯Êý³É¹¦");
        
        //³õʼ»¯¼ÓÃܹ·
       /* {
            //ÓÃÓÚ½«¼ÓÃÜËøÊý¾ÝÈ«²¿³õʼ»¯
            int ret = mD8.ReSet(DevicePath);
            if (ret != 0)
            {
                System.out.println("³õʼ»¯Ê§°Ü");
            }
            System.out.println("³õʼ»¯³É¹¦¡£");
        }*/
        //ÊͷżÓÃܹ·ÄÚ´æ
        mD8.CloseUsbHandle(DevicePath);
    
        
    }
}