📄 root.frm
字号:
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'安装KEY
mbRet = MW.Write_Key_Psam(geU_WordInstall, "", psTransCode, "0100000001113312345678901234567890123456789012")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Write_Key_Psam(geU_WordInstall, "", "12345678901234567890123456789012", "0100091100110012345678901234567890123456789012")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Write_Key_Psam(geU_WordInstall, "", "12345678901234567890123456789012", "010008110011ff12345678901234567890123456789012")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Write_Key_Psam(geU_WordInstall, "", "12345678901234567890123456789012", "01000b000111331234")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Write_Key_Psam(geU_WordInstall, "", "12345678901234567890123456789012", "01000a000111331234")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Create_File_Psam(geU_CreateEndMF, "")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
MsgBox "主密钥认证卡生成成功.", vbInformation, "提示信息"
End Sub
Private Sub Command4_Click()
Dim psRet As String
Dim pbRandom(8) As Byte
Dim psMac As String
Dim pbOut(8) As Byte
Dim pbIn(10) As Byte
Dim psTransCode As String
'第一步:读传输代码.
MsgBox "请在下卡座插入生厂商认证卡", vbInformation, "提示信息"
mbRet = MW.Sam_Reset
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_Verify("1234")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_Read_Binary("82", 2, 8, pbOut())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Hex_To_Asc(pbOut(0), psTransCode, 8)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'第二步:相互认证
MsgBox "请在上卡座插入根密钥认证卡,下卡座插入根密钥卡.", vbInformation, "提示信息"
mbRet = MW.Reset
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_Reset
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_Get_Challenge_Psam(geU_Random8, pbRandom())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
MsgBox "取得PIN", vbInformation, "提示信息"
mbRet = MW.Verify_Psam("1234")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Internal_Authentication_Psam("01", pbRandom(), pbOut())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_External_Authentication_Psam("02", pbOut())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'第四步:建Psam卡.
MsgBox "请在上卡座插入要发行的Psam卡", vbInformation, "提示信息"
mbRet = MW.Reset
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Delete
If Not mbRet Then MsgBox MW.Errshow
mbRet = MW.Create_File_Psam(geU_CreateMF, "FFFFFFFFFFFFFFFF0f011234567890")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建ATR文件
mbRet = MW.Create_File_Psam(geU_CreateEF, "0001040ff0000a")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Asc_To_Hex("05000000000000000020", pbIn(0), 10)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'写ATR文件
mbRet = MW.Update_Binary_Psam(geU_Data, "81", 0, 10, pbIn())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建KEY文件
mbRet = MW.Create_File_Psam(geU_CreateEF, "0002C511801019")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'安装KEY
mbRet = MW.Write_Key_Psam(geU_EncryptInstall, "", psTransCode, "01000000010F3312345678901234567890123456789012")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Get_Challenge_Psam(geU_Random4, pbRandom())
If Not mbRet Then MsgBox MW.Errshow
pbRandom(4) = 0
pbRandom(5) = 0
pbRandom(6) = 0
pbRandom(7) = 0
mwret = MW.Hex_To_Asc(pbRandom(0), psMac, 8)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_OUT_KEY_Psam("61", "01", "84d40000070100480f000fff" + psMac, psRet)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Write_Key_Psam(geU_OUTKEY_EncryptInstall, "", "12345678901234567890123456789012", psRet)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Write_Key_Psam(geU_EncryptInstall, "", "12345678901234567890123456789012", "0100010f000Fff12345678901234567890123456789012")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Create_File_Psam(geU_CreateEndMF, "")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
MsgBox "生成Psam卡成功.", vbInformation, "提示信息"
End Sub
Private Sub Command5_Click()
Dim pbOut(8) As Byte
Dim pbIn(10) As Byte
Dim psTransCode As String
Dim pbRandom(8) As Byte
'第一步:读传输代码.
MsgBox "请在下卡座插入生厂商认证卡", vbInformation, "提示信息"
mbRet = MW.Sam_Reset
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_Verify("1234")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_Read_Binary("82", 2, 8, pbOut())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Hex_To_Asc(pbOut(0), psTransCode, 8)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'第二步:相互认证
MsgBox "请在上卡座插入主密钥认证卡,下卡座插入主密钥卡.", vbInformation, "提示信息"
mbRet = MW.Reset
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_Reset
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_Get_Challenge_Psam(geU_Random8, pbRandom())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
MsgBox "取得PIN", vbInformation, "提示信息"
mbRet = MW.Verify_Psam("1234")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Internal_Authentication_Psam("01", pbRandom(), pbOut())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_External_Authentication_Psam("02", pbOut())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'第三步:取得卡序列号
MsgBox "取得卡序列号", vbInformation, ""
'第四步:建用户卡.
MsgBox "请在上卡座插入要发行的用户卡", vbInformation, "提示信息"
mbRet = MW.Reset
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Create_File(geU_CreateEndMF, "")
mbRet = MW.Delete
If Not mbRet Then MsgBox MW.Errshow
mbRet = MW.Create_File(geU_CreateMF, "FFFFFFFFFFFFFFFF0f011234567890")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建ATR文件
mbRet = MW.Create_File(geU_CreateEF, "0001040ff0000a")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Asc_To_Hex("06000000000000000030", pbIn(0), 10)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'写ATR文件
mbRet = MW.Update_Binary(geU_Data, "81", 0, 10, pbIn())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建KEY文件
mbRet = MW.Create_File(geU_CreateEF, "00020511001019")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'安装KEY
mbRet = MW.Write_Key(geU_WordInstall, "", "", "010100080001113312345678901234567890123456789012")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Write_Key(geU_WordInstall, "", "", "010100050f000fff12345678901234567890123456789012")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
Dim psRet As String
mbRet = MW.Sam_OUT_KEY_Psam("80", "01", "0000000000000030", psRet)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Write_Key(geU_WordInstall, "", "", "0201000800011133" + psRet)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Write_Key(geU_WordInstall, "", "", "01010006000f0fff12345678901234567890123456789012")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Write_Key(geU_WordInstall, "", "", "0101000b000f0fff1234")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建文件1保存城市代码,发卡时间等.
mbRet = MW.Create_File(geU_CreateEF, "0003000ff00020")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Asc_To_Hex("0351000000000000", pbIn(0), 8)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Update_Binary(geU_Data, "83", 0, 8, pbIn())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Asc_To_Hex(Format(Now, "yyyymmdd"), pbIn(0), 4)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Update_Binary(geU_Data, "83", 8, 4, pbIn())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建文件2 用来保存公共信息:存款人银行标识,行政区划编码,机构......
mbRet = MW.Create_File(geU_CreateEF, "0004000ff000FF")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
Dim pbInfo(60) As Byte
Dim PsBankId As String
Dim psArea As String
Dim psInstitution As String
Dim psShang As String
Dim psCompany As String
Dim psPerson As String
Dim psPaper As String
PsBankId = "123456789012345678"
psArea = "123456"
psInstitution = "123456789"
psShang = "12345678"
psCompany = "123456789012345678901234567890"
psPerson = "123456"
psPaper = "123456789012345678"
'BankID
mbRet = MW.ChineseString_DoubleByte(PsBankId, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Update_Binary(geU_Data, "84", 0, 36, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'Area
mbRet = MW.ChineseString_DoubleByte(psArea, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Update_Binary(geU_Data, "84", 36, 12, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'Institution
mbRet = MW.ChineseString_DoubleByte(psInstitution, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Update_Binary(geU_Data, "84", 48, 18, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'Shang
mbRet = MW.ChineseString_DoubleByte(psShang, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Update_Binary(geU_Data, "84", 66, 16, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'Company30个字符
mbRet = MW.ChineseString_DoubleByte(psCompany, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Update_Binary(geU_Data, "84", 82, 60, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'Person6个字符
mbRet = MW.ChineseString_DoubleByte(psPerson, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Update_Binary(geU_Data, "84", 142, 12, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'Papar
mbRet = MW.ChineseString_DoubleByte(psPaper, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Update_Binary(geU_Data, "84", 154, 36, pbInfo())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建ADF1 招行应用.
mbRet = MW.Create_File(geU_CreateDF, "0010f0001111111111")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建ADF1下的key.
mbRet = MW.Create_File(geU_CreateEF, "00110511001019")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建ADF1下的EF.
mbRet = MW.Create_File(geU_CreateEF, "00120011110030")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Create_File(geU_CreateEndDF, "0010")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建ADF2 工行应用.
mbRet = MW.Create_File(geU_CreateDF, "0020f0001111111111")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建ADF2下的key.
mbRet = MW.Create_File(geU_CreateEF, "00210511001019")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
'建ADF2下的EF.
mbRet = MW.Create_File(geU_CreateEF, "00220011110030")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Create_File(geU_CreateEndDF, "0020")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Create_File(geU_CreateEndMF, "")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
MsgBox "生成用户卡成功.", vbInformation, "提示信息"
End Sub
Private Sub Command6_Click()
Dim psOut As String * 16
Dim psIn As String * 16
Dim pbRandom(8) As Byte
Dim pbEncrypt(8) As Byte
mbRet = MW.Reset
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_Reset
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
MsgBox "请在下卡座插入PSAM认证卡,在上卡座插入用户卡", vbInformation, "提示信息"
mbRet = MW.sam_INIT_FOR_DESCRYPT_Psam("48", "01", "00000000000000301234567890123456")
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Get_Challenge(geU_Random8, pbRandom())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Hex_To_Asc(pbRandom(0), psIn, 8)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Sam_DES_CRYPT_Psam("00", psIn, psOut)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.Asc_To_Hex(psOut, pbEncrypt(0), 8)
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
mbRet = MW.External_Authentication("02", pbEncrypt())
If Not mbRet Then MsgBox MW.Errshow: Exit Sub
End Sub
Private Sub Command7_Click()
End Sub
Private Sub Form_Load()
Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
mbRet = MW.Com_Open(geU_Com1, geU_Baud9600)
If Not mbRet Then MsgBox MW.Errshow
End Sub
Private Sub Form_Unload(Cancel As Integer)
mbRet = MW.Com_Close
If Not mbRet Then MsgBox MW.Errshow
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -