
本示例使用的发卡器:https://item.taobao.com/item.htm?spm=a21dvs.23580594.0.0.4fee2c1bf4TuBP&ft=t&id=615391857885
javascript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MifareDesfireEv123卡读写DEMO</title>
<script language="javascript">
var iswsrun = false;
var ws;
var received_msg = "";
var mytimer;
var strls = "";
var errorno = "";
var time1;
var wsUri = "ws://127.0.0.1:39189"; //端口号必须与RFIDWebServer端口一致
function isUIntNum(val) {
var testval = /^\d+$/; // 非负整数
return (testval.test(val));
}
function isHex(val) {
var testval = /^(\d|[A-F]|[a-f])+$/; // 十六进制数判断
return (testval.test(val));
}
function ButtonDisable() { //删除按键的 onclick 事件,防止重复执行指令
document.getElementById("butt_beep").setAttribute("onclick", null);
document.getElementById("butt_getdevnum").setAttribute("onclick", null);
document.getElementById("butt_getcardtype").setAttribute("onclick", null);
document.getElementById("butt_piccrequest").setAttribute("onclick", null);
document.getElementById("butt_selectaid").setAttribute("onclick", null);
document.getElementById("butt_desfireauthkeyev1").setAttribute("onclick", null);
document.getElementById("butt_desfirechangekeyev1").setAttribute("onclick", null);
document.getElementById("butt_desfireauthkeyev2").setAttribute("onclick", null);
document.getElementById("butt_getPICCkeysettings").setAttribute("onclick", null);
document.getElementById("butt_changePICCkeysettings").setAttribute("onclick", null);
document.getElementById("butt_formatpicc").setAttribute("onclick", null);
document.getElementById("butt_getapplicationids").setAttribute("onclick", null);
document.getElementById("butt_createapplication").setAttribute("onclick", null);
document.getElementById("butt_getappkeysettings").setAttribute("onclick", null);
document.getElementById("butt_changeappkeysettings").setAttribute("onclick", null);
document.getElementById("butt_deleteapplication").setAttribute("onclick", null);
document.getElementById("butt_getfileids").setAttribute("onclick", null);
document.getElementById("butt_createstfile").setAttribute("onclick", null);
document.getElementById("butt_getfilesettings").setAttribute("onclick", null);
document.getElementById("butt_changefilesettings").setAttribute("onclick", null);
document.getElementById("butt_deletefile").setAttribute("onclick", null);
document.getElementById("butt_readfile").setAttribute("onclick", null);
document.getElementById("butt_writefile").setAttribute("onclick", null);
document.getElementById("butt_createdata").setAttribute("onclick", null);
document.getElementById("butt_committransaction").setAttribute("onclick", null);
document.getElementById("butt_aborttransaction").setAttribute("onclick", null);
}
function SelectEv1AuthMode() { //选择不同的密钥方式,得到默认的密钥长度
switch (ComboxEv1AuthMode.selectedIndex) {
case 0:
text_authkey.value = "00 00 00 00 00 00 00 00";
break;
case 1:
text_authkey.value = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
break;
case 2:
text_authkey.value = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
break;
default:
text_authkey.value = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
}
}
function SelectNewKeyMode() {
switch (ComboxNewKeyMode.selectedIndex) {
case 0:
text_authkey.value = "00 00 00 00 00 00 00 00";
text_newkey.value = "00 00 00 00 00 00 00 00";
break;
case 1:
text_authkey.value = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
text_newkey.value = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
break;
case 2:
text_authkey.value = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
text_newkey.value = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
break;
default:
text_authkey.value = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
text_newkey.value = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
}
}
function beep() { //驱动发卡器响声令
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
WebSocketRun("pcdbeep,30");
}
function getdevicenumber() { //读取发卡器唯一出厂序号,可以当加密狗使用
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
serialnumber.value="";
WebSocketRun("pcdgetdevicenumber");
}
function geticcardtype() { //获取IC卡型号
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
WebSocketRun("getmifareversion");
}
function cpurequest1() { //激活PICC
ButtonDisable();
textarea.value = "";
carduid.value = "";
WebSocketRun("cpurequest1,");
}
function desfireselectapplication() { //选择应用
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
aidstr = text_selectaid.value.trim().replace(/\s+/g, ''); //选择的aid,十六进制,去除空格
if (!isHex(aidstr) || aidstr.length != 6) {
alert( "AID输入错误,请输入正确的6位16进制AID!");
text_selectaid.focus();
text_selectaid.select();
ButtonEnabled();
return;
}
WebSocketRun("desfireselectapplication," + aidstr);
}
function desfireauthkeyev1() { //ev123卡密钥认证
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
keyid = text_authkeyid.value.trim(); //认证密钥编号
if (!isUIntNum(keyid)) {
alert( "认证密钥编号输入错误!");
text_authkeyid.focus();
text_authkeyid.select();
ButtonEnabled();
return;
}
keytype = ComboxEv1AuthMode.selectedIndex; //加解密方式
switch (keytype) { //根据加密方式得到密钥长度
case 0:
keylen = 16;
break;
case 1:
keylen = 32;
break;
case 2:
keylen = 48;
break;
default:
keylen = 32;
}
authkeystr = text_authkey.value.trim().replace(/\s+/g, ''); //16进制的认证密钥
if (!isHex(authkeystr) || authkeystr.length != keylen) {
alert( "认证密钥输入错误,请输入正确的16进制认证密钥!");
text_authkey.focus();
text_authkey.select();
ButtonEnabled();
return;
}
WebSocketRun("desfireauthkeyev1," + authkeystr + "," + keyid + "," + keytype);
}
function desfirechangekeyev1() { //更改卡片密钥
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
keyid = text_newkeyid.value.trim(); //需要更改的密钥编号
if (!isUIntNum(keyid)) {
alert( "需更改的密钥编号输入错误!");
text_newkeyid.focus();
text_newkeyid.select();
ButtonEnabled();
return;
}
keytype = ComboxNewKeyMode.selectedIndex; //新加解密方式
switch (keytype) { //根据加密方式得到密钥长度
case 0:
keylen = 16;
break;
case 1:
keylen = 32;
break;
case 2:
keylen = 48;
break;
default:
keylen = 32;
}
authkeystr = text_authkey.value.trim().replace(/\s+/g, ''); //16进制的卡片旧密钥
if (!isHex(authkeystr) || authkeystr.length != keylen) {
alert( "旧认证密钥输入错误,请输入正确的16进制旧认证密钥!");
text_authkey.focus();
text_authkey.select();
ButtonEnabled();
return;
}
newkeystr = text_newkey.value.trim().replace(/\s+/g, ''); //16进制的卡片新密钥
if (!isHex(newkeystr) || newkeystr.length != keylen) {
alert( "新密钥输入错误,请输入正确的16进制新密钥!");
text_newkey.focus();
text_newkey.select();
ButtonEnabled();
return;
}
WebSocketRun("desfirechangekeyev1," + newkeystr + "," + keyid + "," + keytype + "," + authkeystr);
}
function desfireauthkeyev2() { //EV2 EV3卡AES密钥认证"
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
keyid = textaeskeyid.value.trim(); //认证密钥编号
if (!isUIntNum(keyid)) {
alert( "认证密钥编号输入错误!");
textaeskeyid.focus();
textaeskeyid.select();
ButtonEnabled();
return;
}
keytype = ComboxAESMode.selectedIndex; //加解密方式
keylen = 32; //密钥长度
authkeystr = text_aeskey.value.trim().replace(/\s+/g, ''); //16进制的认证密钥
if (!isHex(authkeystr) || authkeystr.length != keylen) {
alert( "AES认证密钥输入错误,请输入正确的16进制AES认证密钥!");
text_aeskey.focus();
text_aeskey.select();
ButtonEnabled();
return;
}
WebSocketRun("desfireauthkeyev2," + authkeystr + "," + keyid + "," + keytype);
}
function desfiregetpicckeysettings() { //获取PICC主密钥配置信息
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
aidstr = "000000"; //"000000"表示PICC
WebSocketRun("desfiregetkeysettings," + aidstr );
}
function desfirechangepicckeysettings() { //更改PICC主密钥配置信息
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
aidstr = "000000"; //"000000"表示PICC
if (ComboxEditPICCSet.selectedIndex == 0) {
alert("为防止测试导致卡片产生不可逆的后果,在本例子中不允许锁定配值!");
ComboxEditPICCSet.selectedIndex = 1;
}
keysetting = ComboxEditPICCSet.selectedIndex * 8 + ComboxCreateApp.selectedIndex * 4 + ComboxGetAid.selectedIndex * 2 + ComboxPICCMasterKey.selectedIndex;
WebSocketRun("desfirechangekeysettings," + aidstr + "," + keysetting);
}
function desfireformatpicc() { //初始格式化PICC
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
WebSocketRun("desfireformatpicc" );
}
function desfiregetapplicationids() { //搜索当前卡片内所有应用AID
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
WebSocketRun("desfiregetapplicationids");
}
function desfirecreateapplication() { //在PICC上创建新应用
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
aidstr = text_editaid.value.trim().replace(/\s+/g, ''); //新创建的aid,十六进制,去除空格
if (!isHex(aidstr) || aidstr.length != 6) {
alert( "AID输入错误,请输入正确的6位16进制AID!");
text_editaid.focus();
text_editaid.select();
ButtonEnabled();
return;
}
if (aidstr == "000000") {
alert("在这里不能操作PICC级AID为00 00 00的主应用!");
text_editaid.value = "00 00 01";
text_editaid.focus();
text_editaid.select();
ButtonEnabled();
return;
}
keyids = text_keys.value.trim(); //密钥数量
if (!isUIntNum(keyids) || keyids < 1 || keyids > 14) {
alert( "密钥数量取值范围:1-14 !");
text_keys.focus();
text_keys.select();
ButtonEnabled();
return;
}
Encry = ComboxAppEncrMode.selectedIndex; //加解密方式
keysetting = ComboxEditAppKey.selectedIndex * 16 + ComboxEditConfigKey.selectedIndex * 8 + ComboxCreateFile.selectedIndex * 4 + ComboxGetFileID.selectedIndex * 2 + ComboxMasterKey.selectedIndex; //APP密钥配置参数
WebSocketRun("desfirecreateapplication," + aidstr + "," + keysetting + "," + keyids + "," + Encry);
}
function desfiregetkeysettings() { //读取应用的密钥配置信息
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
aidstr = text_editaid.value.trim().replace(/\s+/g, ''); //要读取配置的aid,十六进制,去除空格
if (!isHex(aidstr) || aidstr.length != 6) {
alert("AID输入错误,请输入正确的6位16进制AID!");
text_editaid.focus();
text_editaid.select();
ButtonEnabled();
return;
}
if (aidstr == "000000") {
alert("在这里不能操作PICC级AID为00 00 00的主应用!");
text_editaid.value = "00 00 01";
text_editaid.focus();
text_editaid.select();
ButtonEnabled();
return;
}
WebSocketRun("desfiregetkeysettings," + aidstr);
}
function desfirechangekeysettings() { //更改应用的密钥配置
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
aidstr = text_editaid.value.trim().replace(/\s+/g, ''); //要更改配置的aid,十六进制,去除空格
if (!isHex(aidstr) || aidstr.length != 6) {
alert("AID输入错误,请输入正确的6位16进制AID!");
text_editaid.focus();
text_editaid.select();
ButtonEnabled();
return;
}
if (aidstr == "000000") {
alert("在这里不能操作PICC级AID为00 00 00的主应用!");
text_editaid.value = "00 00 01";
text_editaid.focus();
text_editaid.select();
ButtonEnabled();
return;
}
keysetting = ComboxEditAppKey.selectedIndex * 16 + ComboxEditConfigKey.selectedIndex * 8 + ComboxCreateFile.selectedIndex * 4 + ComboxGetFileID.selectedIndex * 2 + ComboxMasterKey.selectedIndex; //APP密钥配置参数
WebSocketRun("desfirechangekeysettings," + aidstr + "," + keysetting);
}
function desfiredeleteapplication() { //删除应用
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
aidstr = text_editaid.value.trim().replace(/\s+/g, ''); //要删除的aid,十六进制,去除空格
if (!isHex(aidstr) || aidstr.length != 6) {
alert("AID输入错误,请输入正确的6位16进制AID!");
text_editaid.focus();
text_editaid.select();
ButtonEnabled();
return;
}
if (aidstr == "000000") {
alert("在这里不能操作PICC级AID为00 00 00的主应用!");
text_editaid.value = "00 00 01";
text_editaid.focus();
text_editaid.select();
ButtonEnabled();
return;
}
WebSocketRun("desfiredeleteapplication," + aidstr);
}
function desfiregetfileids() { //搜索当前App应用内所有文件fileId
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
WebSocketRun("desfiregetfileids");
}
function createstfile() { //在App应用内创建新文件
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
fileid = text_fileid.value.trim(); //需要创建的新文件编号
if (!isUIntNum(fileid)) {
alert("文件ID有非法数值!");
text_fileid.focus();
text_fileid.select();
ButtonEnabled();
return;
}
filebytes = text_filesize.value.trim(); //需要创建的新文件空间大小
if (!isUIntNum(filebytes)) {
alert("文件空间有非法数值!");
text_filesize.focus();
text_filesize.select();
ButtonEnabled();
return;
}
comset = 3; //通讯模式
if (ComboxConnMode.selectedIndex < 2) {
comset = ComboxConnMode.selectedIndex;
}
accessrights = ComboxRWFileKey.selectedIndex * 16 + ComboxEditFileConfigKey.selectedIndex + (ComboxReadFileKey.selectedIndex * 16 + ComboxWriteFileKey.selectedIndex) * 256; //文件读写权限
if (ComboxFileType.selectedIndex < 1) {
WebSocketRun("desfirecreatestddatafile," + fileid + "," + comset + "," + accessrights + "," + filebytes); //创建标准数据文件
} else {
WebSocketRun("desfircreatebackupdatafile," + fileid + "," + comset + "," + accessrights + "," + filebytes); //创建事务备份文件
}
}
function desfiregetfilesettings() { //读取文件的配置信息
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
fileid = text_fileid.value.trim(); //需要读取配置的文件编号
if (!isUIntNum(fileid)) {
alert("文件ID有非法数值!");
text_fileid.focus();
text_fileid.select();
ButtonEnabled();
return;
}
WebSocketRun("desfiregetfilesettings," + fileid);
}
function desfirechangefilesettings() { //更改文件的配置信息
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
fileid = text_fileid.value.trim(); //需要更改配置的文件编号
if (!isUIntNum(fileid)) {
alert("文件ID有非法数值!");
text_fileid.focus();
text_fileid.select();
ButtonEnabled();
return;
}
comset = 3; //通讯模式
if (ComboxConnMode.selectedIndex < 2) {
comset = ComboxConnMode.selectedIndex;
}
accessrights = ComboxRWFileKey.selectedIndex * 16 + ComboxEditFileConfigKey.selectedIndex + (ComboxReadFileKey.selectedIndex * 16 + ComboxWriteFileKey.selectedIndex) * 256; //文件读写权限
WebSocketRun("desfirechangefilesettings," + fileid + "," + comset + "," + accessrights);
}
function desfiredeletefile() { //删除App应用内的文件
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
fileid = text_fileid.value.trim(); //需要删除的文件编号
if (!isUIntNum(fileid)) {
alert("文件ID有非法数值!");
text_fileid.focus();
text_fileid.select();
ButtonEnabled();
return;
}
WebSocketRun("desfiredeletefile," + fileid );
}
function desfirereaddata() { //读文件
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
text_dataarea.value = "";
fileid = text_fileid.value.trim(); //需要读的文件编号
if (!isUIntNum(fileid)) {
alert("文件ID有非法数值!");
text_fileid.focus();
text_fileid.select();
ButtonEnabled();
return;
}
rwbegin = text_rwstar.value.trim(); //读起始位置
if (!isUIntNum(rwbegin)) {
alert("读起始位置输入错误!");
text_rwstar.focus();
text_rwstar.select();
ButtonEnabled();
return;
}
rwlen = text_rwsize.value.trim(); //读取数据长度
if (!isUIntNum(rwlen)) {
alert("读取数据长度输入错误!");
text_rwsize.focus();
text_rwsize.select();
ButtonEnabled();
return;
}
WebSocketRun("desfirereaddata," + fileid + "," + rwbegin + "," + rwlen);
}
function desfirewritedata() { //写文件
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
fileid = text_fileid.value.trim(); //需要写的文件编号
if (!isUIntNum(fileid)) {
alert("文件ID有非法数值!");
text_fileid.focus();
text_fileid.select();
ButtonEnabled();
return;
}
rwbegin = text_rwstar.value.trim(); //读写起始位置
if (!isUIntNum(rwbegin)) {
alert("读写起始位置输入错误!");
text_rwstar.focus();
text_rwstar.select();
ButtonEnabled();
return;
}
rwlen = text_rwsize.value.trim(); //读写数据长度
if (!isUIntNum(rwlen)) {
alert("读写数据长度输入错误!");
text_rwsize.focus();
text_rwsize.select();
ButtonEnabled();
return;
}
datastr = text_dataarea.value.trim().replace(/\s+/g, ''); //写卡数据,十六进制,去除空格
if (!isHex(datastr) || datastr.length != rwlen*2) {
alert("写卡数据不足或写卡数据错误,请输入 " + (rwlen * 2).toString() +" 位16进制的写卡数据!");
text_dataarea.focus();
text_dataarea.select();
ButtonEnabled();
return;
}
WebSocketRun("desfirewritedata," + fileid + "," + rwbegin + "," + rwlen + "," + datastr);
}
function createdatastr() { //生成写卡数据
rwlen = text_rwsize.value.trim(); //读取数据长度
if (!isUIntNum(rwlen)) {
alert("数据长度输入错误!");
text_rwsize.focus();
text_rwsize.select();
}
let datastr = "";
for (let i = 0; i < rwlen; i++) {
datastr = datastr + i.toString(16).padStart(2, '0').toUpperCase().slice(-2) + " ";
}
text_dataarea.value = datastr;
}
function desfirecommittransaction() { //提交事务使备份生效
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
WebSocketRun("desfirecommittransaction");
}
function desfireaborttransaction() { //取消事务
ButtonDisable(); //删除按键的 onclick 事件,防止重复执行指令
textarea.value = "";
WebSocketRun("desfireaborttransaction");
}
function ButtonEnabled() { //恢复各button 的onclick事件
document.getElementById("butt_beep").setAttribute("onclick", "beep()");
document.getElementById("butt_getdevnum").setAttribute("onclick", "getdevicenumber()");
document.getElementById("butt_getcardtype").setAttribute("onclick", "geticcardtype()");
document.getElementById("butt_piccrequest").setAttribute("onclick", "cpurequest1()");
document.getElementById("butt_selectaid").setAttribute("onclick", "desfireselectapplication()");
document.getElementById("butt_desfireauthkeyev1").setAttribute("onclick", "desfireauthkeyev1()");
document.getElementById("butt_desfirechangekeyev1").setAttribute("onclick", "desfirechangekeyev1()");
document.getElementById("butt_desfireauthkeyev2").setAttribute("onclick", "desfireauthkeyev2()");
document.getElementById("butt_getPICCkeysettings").setAttribute("onclick", "desfiregetpicckeysettings()");
document.getElementById("butt_changePICCkeysettings").setAttribute("onclick", "desfirechangepicckeysettings()");
document.getElementById("butt_formatpicc").setAttribute("onclick", "desfireformatpicc()");
document.getElementById("butt_getapplicationids").setAttribute("onclick", "desfiregetapplicationids()");
document.getElementById("butt_createapplication").setAttribute("onclick", "desfirecreateapplication()");
document.getElementById("butt_getappkeysettings").setAttribute("onclick", "desfiregetkeysettings()");
document.getElementById("butt_changeappkeysettings").setAttribute("onclick", "desfirechangekeysettings()");
document.getElementById("butt_deleteapplication").setAttribute("onclick", "desfiredeleteapplication()");
document.getElementById("butt_getfileids").setAttribute("onclick", "desfiregetfileids()");
document.getElementById("butt_createstfile").setAttribute("onclick", "createstfile()");
document.getElementById("butt_getfilesettings").setAttribute("onclick", "desfiregetfilesettings()");
document.getElementById("butt_changefilesettings").setAttribute("onclick", "desfirechangefilesettings()");
document.getElementById("butt_deletefile").setAttribute("onclick", "desfiredeletefile()");
document.getElementById("butt_readfile").setAttribute("onclick", "desfirereaddata()");
document.getElementById("butt_writefile").setAttribute("onclick", "desfirewritedata()");
document.getElementById("butt_createdata").setAttribute("onclick", "createdatastr()");
document.getElementById("butt_committransaction").setAttribute("onclick", "desfirecommittransaction()");
document.getElementById("butt_aborttransaction").setAttribute("onclick", "desfireaborttransaction()");
}
function DispErrInfo(errcode){
var errstr = "";
switch (errcode) {
case "ReturnCode:001":
case "ReturnCode:002":
errstr = ",读写1、2块数据失败!";
errstr = ",读写扇区数据失败!";
break;
break;
case "ReturnCode:003":
errstr = ",读写第2块数据失败!";
break;
case "ReturnCode:008":
errstr = ",未寻到卡,请将卡放到发卡器的感应区!";
break;
case "ReturnCode:009":
errstr = ",有多张卡在感应区,寻卡过程中防冲突失败,读卡失败!";
break;
case "ReturnCode:010":
errstr = ",该卡可能已被休眠,无法选中卡片!";
break;
case "ReturnCode:011":
errstr = ",密码装载失败!";
break;
case "ReturnCode:012":
errstr = ",卡密码认证失败!";
break;
case "ReturnCode:013":
errstr = ",读块操作失败,原因是刷卡太快或本块所对应的区还没通过密码认证!";
break;
case "ReturnCode:014":
errstr = ",写块操作失败,原因是刷卡太快或本块所对应的区还没通过密码认证!";
break;
case "ReturnCode:018":
errstr = ",写块操作失败!";
break;
case "ReturnCode:021":
errstr = ",没有动态库!";
break;
case "ReturnCode:022":
errstr = ",动态库或驱动程序异常!";
break;
case "ReturnCode:023":
errstr = ",驱动程序错误或发卡器未连接!";
break;
case "ReturnCode:024":
errstr = ",操作超时,一般是动态库没有反映!";
break;
case "ReturnCode:025":
errstr = ",发送字数不够!";
break;
case "ReturnCode:026":
errstr = ",发送的CRC错!";
break;
case "ReturnCode:027":
errstr = ",接收的字数不够!";
break;
case "ReturnCode:028":
errstr = ",接收的CRC错!";
break;
case "ReturnCode:029":
errstr = ",函数输入参数格式错误!";
break;
case "ReturnCode:444":
errstr = ",RFIDWebServer系统文件错误!";
break;
default:
errstr = ",未知的错误!";
}
return errstr;
}
window.onerror = function (e) {
ButtonEnabled(); //恢复按键的onclick事件
clearInterval(time1);
document.getElementById('butt_readloop').value = '轮询读取IC卡卡号';
alert("不好意思,出错了!");
return true;//屏蔽系统事件
}
function timeoutevent() {
ws.close();
textarea.value = "websockket返回超时";
ButtonEnabled(); //恢复按键的onclick事件
clearInterval(time1);
document.getElementById('butt_readloop').value = '轮询读取IC卡卡号';
}
//websockket数据处理
function WebSocketRev(evt) {
clearTimeout(mytimer);
received_msg = evt.data;
ws.close();
//在这里解析返回数据
var strlist = received_msg.split(",");
if (strlist.length > 1) {
var dispstr = "";
switch (strlist[0]) {
case "pcdbeep":
dispstr = "函数名称:" + strlist[0] + "\r\n";
if (strlist[1] == "ReturnCode:000") {
dispstr = dispstr + "操作结果:" + strlist[1];
dispstr = dispstr + ",已执行蜂鸣响声操作!\r\n";
} else {
dispstr = dispstr + "操作结果:" + strlist[1];
dispstr = dispstr + DispErrInfo(strlist[1]);
}
textarea.value = dispstr;
break;
case "pcdgetdevicenumber":
dispstr = "函数名称:" + strlist[0] + "\r\n";
if (strlist[1] == "ReturnCode:000") {
dispstr = dispstr + "操作结果:" + strlist[1];
dispstr = dispstr + ",已读取设备编号!\r\n";
} else {
dispstr = dispstr + "操作结果:" + strlist[1];
dispstr = dispstr + DispErrInfo(strlist[1]);
}
if (strlist.length > 2) {
dispstr = dispstr + "设备编号:" + strlist[2] + "\r\n";
serialnumber.value=strlist[2];
}
textarea.value = dispstr;
break;
case "getmifareversion":
dispstr = "函数名称:" + strlist[0] + "\r\n";
if (strlist[1] == "ReturnCode:000") {
dispstr = dispstr + "操作结果:" + strlist[1];
dispstr = dispstr + ",读取IC卡型号成功!\r\n";
dispstr = dispstr + "ATQA:" + strlist[2] + "\r\n";
dispstr = dispstr + "ASK:" + strlist[3] + "\r\n";
dispstr = dispstr + "型号:" + strlist[4] + "\r\n";
} else {
dispstr = dispstr + "操作结果:" + strlist[1];
dispstr = dispstr + DispErrInfo(strlist[1]);
}
if (strlist.length > 5) {
dispstr = dispstr + "Version:" + strlist[5] + "\r\n";
}
textarea.value = dispstr;
break;
case "cpurequest1":
dispstr = "函数名称:" + strlist[0] + "\r\n";
if (strlist[1] == "ReturnCode:000" || strlist[1] == "ReturnCode:052") {
dispstr = dispstr + "操作结果:" + strlist[1] + ",卡已激活!\r\n";
dispstr = dispstr + "16进制卡号:" + strlist[2] + "\r\n";
dispstr = dispstr + "卡片参数:" + strlist[4] + "\r\n";
dispstr = dispstr + "卡片版本:" + strlist[5] + "\r\n";
dispstr = dispstr + "厂家代码:" + strlist[6] + "\r\n";
if (strlist.length > 8) {
dispstr = dispstr + "ATQA:" + strlist[7] + "\r\n";
dispstr = dispstr + "SAK:" + strlist[8] + "\r\n";
}
carduid.value=strlist[2];
} else {
dispstr = dispstr + "操作结果:" + strlist[1];
dispstr = dispstr + DispErrInfo(strlist[1]);
}
textarea.value = dispstr;
break;
case "desfireselectapplication":
dispstr = "执行函数名称:" + strlist[0] + " 选择卡内应用操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfireauthkeyev1":
dispstr = "执行函数名称:" + strlist[0] + " 认证卡片密钥操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfirechangekeyev1":
dispstr = "执行函数名称:" + strlist[0] + " 更改卡片密钥操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfireauthkeyev2":
dispstr = "执行函数名称:" + strlist[0] + " 认证卡片密钥操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfireformatpicc":
dispstr = "执行函数名称:" + strlist[0] + " 初始格式化卡操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfirecreateapplication":
dispstr = "执行函数名称:" + strlist[0] + " 创建新的App应用操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfiredeleteapplication":
dispstr = "执行函数名称:" + strlist[0] + " 删除PICC的App应用操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfirecreatestddatafile":
dispstr = "执行函数名称:" + strlist[0] + " 在当前选定的应用内创建新的标准数据文件操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfircreatebackupdatafile":
dispstr = "执行函数名称:" + strlist[0] + " 在当前选定的应用内创建新的备份文件操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfirechangefilesettings":
dispstr = "执行函数名称:" + strlist[0] + " 修改文件配置参数操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfiredeletefile":
dispstr = "执行函数名称:" + strlist[0] + " 删除卡片内的指定文件操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfirechangekeysettings":
dispstr = "执行函数名称:" + strlist[0] + " 修改App应用的配置信息操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
if (strlist[1] == "ReturnCode:000") {
dispstr = dispstr + "应用编号 AID:" + strlist[4] + "\r\n" //000000表示PICC
}
textarea.value = dispstr;
break;
case "desfiregetkeysettings":
dispstr = "执行函数名称:" + strlist[0] + " 读取App应用的配置信息操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
if (strlist[1] == "ReturnCode:000") {
dispstr = dispstr + "应用编号 AID:" + strlist[4] + "\r\n"
BitKeyset = "00000000" + Number.parseInt(strlist[5], 16).toString(2);
BitKeyset = BitKeyset.substring(BitKeyset.length - 8);
dispstr = dispstr + "应用配置参数:" + strlist[5] +";"+ BitKeyset+"\r\n"
dispstr = dispstr + "应用密钥数量:" + strlist[6] + "\r\n"
dispstr = dispstr + "应用加密方式:" + strlist[7] + "\r\n"
if (strlist[4] == "000000") {
ComboxEditPICCSet.selectedIndex = parseInt(BitKeyset.substring(4, 5));
ComboxCreateApp.selectedIndex = parseInt(BitKeyset.substring(5, 6));
ComboxGetAid.selectedIndex = parseInt(BitKeyset.substring(6, 7));
ComboxPICCMasterKey.selectedIndex = parseInt(BitKeyset.substring(7, 8));
} else {
text_keys.value = strlist[6];
ComboxAppEncrMode.selectedIndex = parseInt(strlist[7]); //0为DES 或 2K3DES,2为3K3des,3为AES'
ComboxEditAppKey.selectedIndex = parseInt(BitKeyset.substring(0, 4),2);
ComboxEditConfigKey.selectedIndex = parseInt(BitKeyset.substring(4, 5));
ComboxCreateFile.selectedIndex = parseInt(BitKeyset.substring(5, 6));
ComboxGetFileID.selectedIndex = parseInt(BitKeyset.substring(6, 7));
ComboxMasterKey.selectedIndex = parseInt(BitKeyset.substring(7, 8));
}
}
textarea.value = dispstr;
break;
case "desfiregetapplicationids":
dispstr = "执行函数名称:" + strlist[0] + " 读取PICC内的App应用数量操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
if (strlist[1] == "ReturnCode:000") {
dispstr = dispstr + "总计应用数量:" + strlist[4] + "\r\n"
dispstr = dispstr + "各应用的 AID:" + strlist[5] + "\r\n"
}
textarea.value = dispstr;
break;
case "desfiregetfileids":
dispstr = "执行函数名称:" + strlist[0] + " 读取当前选定应用内的文件数量操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
if (strlist[1] == "ReturnCode:000") {
dispstr = dispstr + "总计文件数量:" + strlist[4] + "\r\n"
dispstr = dispstr + "各文件FileID:" + strlist[5] + "\r\n"
}
textarea.value = dispstr;
break;
case "desfiregetfilesettings":
dispstr = "执行函数名称:" + strlist[0] + " 读取指定文件的配置信息操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
if (strlist[1] == "ReturnCode:000") {
dispstr = dispstr + "文件配置参数:" + strlist[4] + "\r\n"
dispstr = dispstr + "文件空间大小:" + strlist[5] + "\r\n"
ComboxConnMode.selectedIndex = parseInt(strlist[6]);
ComboxRWFileKey.selectedIndex = parseInt(strlist[4].substring(4, 5), 16);
ComboxEditFileConfigKey.selectedIndex = parseInt(strlist[4].substring(5, 6), 16);
ComboxReadFileKey.selectedIndex = parseInt(strlist[4].substring(6, 7), 16);
ComboxWriteFileKey.selectedIndex = parseInt(strlist[4].substring(7, 8), 16);
}
textarea.value = dispstr;
break;
case "desfirereaddata":
dispstr = "执行函数名称:" + strlist[0] + " 读取指定文件数据操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
if (strlist[1] == "ReturnCode:000") {
text_dataarea.value = strlist[4];
}
textarea.value = dispstr;
break;
case "desfirewritedata":
dispstr = "执行函数名称:" + strlist[0] + " 写文件操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfirecommittransaction":
dispstr = "执行函数名称:" + strlist[0] + " 提交事务使备份生效操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
case "desfireaborttransaction":
dispstr = "执行函数名称:" + strlist[0] + " 取消事务操作\r\n";
dispstr = dispstr + "函数返回结果:" + strlist[1] + "\r\n"
dispstr = dispstr + "卡片返回代码:" + strlist[2] + "\r\n"
dispstr = dispstr + "返回代码说明:" + strlist[3] + "\r\n"
textarea.value = dispstr;
break;
default:
dispstr = "未知的指令,请下载运行最新的RFIDWebPlugin插件!\r\n";
textarea.value = dispstr;
break;
}
}
ButtonEnabled(); //恢复按键的onclick事件
}
function WebSocketRun(sendinfo) {
iswsrun = false;
try {
if ("WebSocket" in window) {
ws = new WebSocket(wsUri);
}
else if ("MozWebSocket" in window) {
ws = new MozWebSocket(wsUri);
}
else {
received_msg = "您的浏览器不支持WebSocket,请选用支持WebSocket的浏览器!";
ButtonEnabled(); //恢复按键的onclick事件
return;
}
clearTimeout(mytimer);
ws.onopen = function (evt) {
ws.send(sendinfo);
iswsrun = true;
mytimer = setTimeout("timeoutevent()", 2000);
};
ws.onmessage = WebSocketRev;
ws.onerror = function (e) {
if (iswsrun != true) {
received_msg = "请先在当前电脑下载>安装>运行我们的服务程序......";
window.open("http://www.bossknow.cn:90/RongShiWebReaderTest/RFIDWebServerSetup_Windows.rar", "top");//打开新窗口
ButtonEnabled(); //恢复按键的onclick事件
clearInterval(time1);
document.getElementById('butt_readloop').value = '轮询读取IC卡卡号';
alert("请先下载>安装>运行我们的服务程序,再刷新本页面......");
}
};
}
catch (ex) {
if (iswsrun != true) {
received_msg = "请先在当前电脑下载>安装>运行我们的服务程序......";
window.open("http://www.bossknow.cn:90/RongShiWebReaderTest/RFIDWebServerSetup_Windows.rar", "top");//打开新窗口
ButtonEnabled(); //恢复按键的onclick事件
clearInterval(time1);
document.getElementById('butt_readloop').value = '轮询读取IC卡卡号';
alert("请先下载>安装>运行我们的服务程序,再刷新本页面......");
}
}
}
</script>
<style>
th {
background-color:#F6FAFF;
color: blue;
font-family:楷体;
}
td {
background-color:#F6FAFF;
font-family:楷体;
}
</style>
</head>
<body>
<table width="1350" height="330" align="center">
<tr>
<th width="200" height="20" scope="row"><input style="width:200px" name="butt_beep" type="submit" id="butt_beep" onclick="beep()" value="驱动发卡器响声" /></th>
<td width="1150">
<input style="width:200px" name="butt_getdevnum" type="submit" id="butt_getdevnum" onclick="getdevicenumber()" value="读取发卡器唯一出厂序列号" />
设备编号:
<input style="color:red;text-align:center;" name="serialnumber" type="text" id="serialnumber" size="8" maxlength="8" />
<input style="width:140px; float :right" name="butt_getcardtype" type="submit" id="butt_getcardtype" onclick="geticcardtype()" value="获取IC卡型号" />
</td>
</tr>
<tr>
<th height="20" scope="row">
<input style="width:200px" name="butt_piccrequest" type="submit" id="butt_piccrequest" onclick="cpurequest1()" value="1、激活Mifare Desfire卡" />
</th>
<td>
<label style="width:300px;">16进制卡号: </label>
<input style="color:red;text-align:center;" name="carduid" type="text" id="carduid" size="20" maxlength="20" />
<label style="color:blue">注意:每次拿开卡重放后都需要激活,才能驱动卡进入14443-4协议状态。</label>
</td>
</tr>
<tr>
<th height="20" scope="row">
<input style="width:200px" name="butt_selectaid" type="submit" id="butt_selectaid" onclick="desfireselectapplication()" value="2、选择卡内已有的应用" />
</th>
<td>
16进制AID:
<input style="color:red;text-align:center;" name="text_selectaid" type="text" id="text_selectaid" value="00 00 00" size="8" maxlength="8" />
<label style="color:blue">注意:00 00 00为主应用,主应用下不能创建文件,必须先在主应用下创建子应用(最多28个),再在子应用内创建可读写的文件。</label>
</td>
</tr>
<tr>
<th height="20" scope="row">
<input style="width:200px" name="butt_desfireauthkeyev1" type="submit" id="butt_desfireauthkeyev1" onclick="desfireauthkeyev1()" value="EV1 EV2 EV3卡密钥认证" />
</th>
<td>
密钥编号:
<input style="color:red;text-align:center;" name="text_authkeyid" type="text" id="text_authkeyid" value="0" size="5" maxlength="5" />
    加解密方法:
<select style="width:140px; color:blue;" name="ComboxEv1AuthMode" id="ComboxEv1AuthMode" onchange="SelectEv1AuthMode()">
<option selected="selected">DES</option>
<option>2K3DES</option>
<option>3K3DES</option>
<option>AES </option>
</select>
    16进制旧认证密钥:
<input style="color:red;text-align:left;" name="text_authkey" type="text" id="text_authkey" value="00 00 00 00 00 00 00 00" size="72" maxlength="72" />
</td>
</tr>
<tr>
<th height="20" scope="row">
<input style="width:200px" name="butt_desfirechangekeyev1" type="submit" id="butt_desfirechangekeyev1" onclick="desfirechangekeyev1()" value="更改卡片密钥" />
</th>
<td>
密钥编号:
<input style="color:red;text-align:center;" name="text_newkeyid" type="text" id="text_newkeyid" value="0" size="5" maxlength="5" />
  新加解密方法:
<select style="width:140px; color:blue;" name="ComboxNewKeyMode" id="ComboxNewKeyMode" onchange="SelectNewKeyMode()">
<option selected="selected">DES</option>
<option>2K3DES</option>
<option>3K3DES</option>
<option>AES </option>
</select>
    16进制新认证密钥:
<input style="color:red;text-align:left;" name="text_newkey" type="text" id="text_newkey" value="00 00 00 00 00 00 00 00 " size="72" maxlength="72" />
</td>
</tr>
<tr>
<th height="20" scope="row">
<input style="width:200px" name="butt_desfireauthkeyev2" type="submit" id="butt_desfireauthkeyev2" onclick="desfireauthkeyev2()" value="EV2 EV3卡AES密钥认证" />
</th>
<td>
密钥编号:
<input style="color:red;text-align:center;" name="textaeskeyid" type="text" id="textaeskeyid" value="0" size="5" maxlength="5" />
   加解密方法:
<select style="color:blue;" name="ComboxAESMode" id="ComboxAESMode">
<option selected="selected">EV2First(命令71h)</option>
<option>EV2NonFirst(命令77h)</option>
</select>
    16进制旧AES密钥:
<input style="color:red;text-align:left;" name="text_aeskey" type="text" id="text_aeskey" value="00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" size="72" maxlength="72" />
</td>
</tr>
<tr>
<th height="20" scope="row">
<input style="width:200px" name="butt_getPICCkeysettings" type="submit" id="butt_getPICCkeysettings" onclick="desfiregetpicckeysettings()" value="读取PICC主控密钥配置" /><br /><br />
<input style="width:200px" name="butt_changePICCkeysettings" type="submit" id="butt_changePICCkeysettings" onclick="desfirechangepicckeysettings()" value="更改PICC主控密钥配置" />
</th>
<td>
       更改PICC密钥配置值:
<select style="color:blue;" name="ComboxEditPICCSet" id="ComboxEditPICCSet">
<option>配置值不允许修改(锁定)</option>
<option selected="selected">需要验证应用主密钥(默认)</option>
</select>
     创建、删除App应用时:
<select style="color:blue;" name="ComboxCreateApp" id="ComboxCreateApp">
<option>需要验证应用主密钥</option>
<option selected="selected">无需验证应用主密钥(默认)</option>
</select><br /><br />
获取App应用ID、密钥配置时:
<select style="color:blue;" name="ComboxGetAid" id="ComboxGetAid">
<option>需要验证应用主密钥</option>
<option selected="selected">无需验证应用主密钥(默认)</option>
</select>
              PICC主密钥:
<select style="color:blue;width:179px" name="ComboxPICCMasterKey" id="ComboxPICCMasterKey">
<option>锁定主密钥</option>
<option selected="selected">允许更改主密钥(默认)</option>
</select>
</td>
</tr>
</table>
<table style="width:1350px; height:20px" align="center">
<tr>
<th width="200" height="15" scope="row">
Desfire卡密钥说明:
</th>
<td style="color:blue">
一、00 00 00为PICC主应用,在主应用下EV1卡可以随意更改加解密方法,EV2/EV3卡从DES改为3K3DES/AES后不能再改回DES(返回917E的提示)。<br>
二、在非主应用下加解密方法是在创建应用时指定的,不能更改(返回911E或917E)。
</td>
</tr>
</table>
<table style="width:1350px; height:20px" align="center">
<tr>
<th>
<label style="color:blue ">
<input style="width:1350px" name="butt_formatpicc" type="submit" id="butt_formatpicc" onclick="desfireformatpicc()" value="初始化(格式化)Desfire卡,返回910E 时用" />
</label>
</th>
</tr>
</table>
<table style="width:1350px; height:300px" align="center" >
<tr>
<th width="675" scope="row">
<p>PICC内的App应用管理
<input style="width:333px; float:right" name="butt_getapplicationids" type="submit" id="butt_getapplicationids" onclick="desfiregetapplicationids()" value="搜索当前卡片内所有应用AID" />
</p>
<input style="width:160px" name="butt_createapplication" type="submit" id="butt_createapplication" onclick="desfirecreateapplication()" value="按以下参数创建新应用" />
<input style="width:160px" name="butt_getappkeysettings" type="submit" id="butt_getappkeysettings" onclick="desfiregetkeysettings()" value="读取应用的密钥配置" />
<input style="width:160px" name="butt_changeappkeysettings" type="submit" id="butt_changeappkeysettings" onclick="desfirechangekeysettings()" value="更改应用的密钥配置" />
<input style="width:160px" name="butt_deleteapplication" type="submit" id="butt_deleteapplication" onclick="desfiredeleteapplication()" value="删除应用" /><br><br >
<table>
<tr>
<th width="300" align="right" scope="row" style="color:black">
16进制AID:
</th>
<td align="left">
<input style="color:red;text-align:center;" name="text_editaid" type="text" id="text_editaid" value="00 00 01" size="8" maxlength="8" />
</td>
</tr>
<tr>
<th width="300" align="right" scope="row" style="color:black">
新应用密钥数量:
</th>
<td align="left">
<input style="color:red;text-align:center;" name="text_keys" type="text" id="text_keys" value="14" size="8" maxlength="8" />
</td>
</tr>
<tr>
<th width="300" align="right" scope="row" style="color:black">
加解密方法:
</th>
<td align="left">
<select style="color:blue;width:85px" name="ComboxAppEncrMode" id="ComboxAppEncrMode">
<option selected="selected">DES</option>
<option>2K3DES</option>
<option>3K3DES</option>
<option>AES</option>
</select>
</td>
</tr>
<tr>
<th width="300" align="right" scope="row" style="color:black">
更改应用密钥(非应用主密钥):
</th>
<td align="left">
<select style="color:blue;width:215px" name="ComboxEditAppKey" id="ComboxEditAppKey">
<option selected="selected">需要验证应用的0号主密钥(默认)</option>
<option>需要验证本应用的1号密钥</option>
<option>需要验证本应用的2号密钥</option>
<option>需要验证本应用的3号密钥</option>
<option>需要验证本应用的4号密钥</option>
<option>需要验证本应用的5号密钥</option>
<option>需要验证本应用的6号密钥</option>
<option>需要验证本应用的7号密钥</option>
<option>需要验证本应用的8号密钥</option>
<option>需要验证本应用的9号密钥</option>
<option>需要验证本应用的10号密钥</option>
<option>需要验证本应用的11号密钥</option>
<option>需要验证本应用的12号密钥</option>
<option>需要验证本应用的13号密钥</option>
<option>要改本号密钥就先验证本号密钥</option>
<option>不允许修改(锁定)</option>
</select>
</td>
</tr>
<tr>
<th width="300" align="right" scope="row" style="color:black">
更改应用密钥配置值:
</th>
<td align="left">
<select style="color:blue;width:215px" name="ComboxEditConfigKey" id="ComboxEditConfigKey">
<option>配置值不允许修改(锁定)</option>
<option selected="selected">需要验证应用主密钥(默认)</option>
</select>
</td>
</tr>
<tr>
<th width="300" align="right" scope="row" style="color:black">
创建文件或删除文件时:
</th>
<td align="left">
<select style="color:blue;width:215px" name="ComboxCreateFile" id="ComboxCreateFile">
<option>需要验证应用主密钥</option>
<option selected="selected">无需验证应用主密钥(默认)</option>
</select>
</td>
</tr>
<tr>
<th width="300" align="right" scope="row" style="color:black">
查找文件ID、文件设置、密钥配置时:
</th>
<td align="left">
<select style="color:blue;width:215px" name="ComboxGetFileID" id="ComboxGetFileID">
<option>需要验证应用主密钥</option>
<option selected="selected">无需验证应用主密钥(默认)</option>
</select>
</td>
</tr>
<tr>
<th width="300" align="right" scope="row" style="color:black">
应用主密钥:
</th>
<td align="left">
<select style="color:blue;width:215px" name="ComboxMasterKey" id="ComboxMasterKey">
<option>锁定主密钥</option>
<option selected="selected">允许更改主密钥(默认)</option>
</select>
</td>
</tr>
</table> <br><br> <br>
</th>
<td align="center">
<p>
<label style="color:red;font-weight:bold "> App应用内的文件管理</label>
<input style="width:333px; float:right" name="butt_getfileids" type="submit" id="butt_getfileids" onclick="desfiregetfileids()" value="搜索当前应用内所有文件ID" />
</p>
<input style="width:160px" name="butt_createstfile" type="submit" id="butt_createstfile" onclick="createstfile()" value="按以下参数创建新文件" />
<input style="width:160px" name="butt_getfilesettings" type="submit" id="butt_getfilesettings" onclick="desfiregetfilesettings()" value="读取文件的密钥配置" />
<input style="width:160px" name="butt_changefilesettings" type="submit" id="butt_changefilesettings" onclick="desfirechangefilesettings()" value="更改文件的密钥配置" />
<input style="width:160px" name="butt_deletefile" type="submit" id="butt_deletefile" onclick="desfiredeletefile()" value="删除文件" /><br /><br />
<table style="color:black">
<tr>
<th width="170px" align="right" scope="row" style="color:black">
文件号FileID:
</th>
<td width="130px" align="left">
<input style="color:red;text-align:center;" name="text_fileid" type="text" id="text_fileid" value="1" size="8" maxlength="8" />
</td>
<td width="170px" align="right">
文件类型:
</td>
<td width="180px" align="left">
<select style="color:blue;width:85px" name="ComboxFileType" id="ComboxFileType">
<option selected="selected">标准文件</option>
<option>备份文件</option>
</select>
</td>
</tr>
<tr>
<th align="right" scope="row" style="color:black">
文件空间(字节数):
</th>
<td align="left">
<input style="color:red;text-align:center;" name="text_filesize" type="text" id="text_filesize" value="256" size="8" maxlength="8" />
</td>
<td align="right">
通讯模式:
</td>
<td align="left">
<select style="color:blue;" name="ComboxConnMode" id="ComboxConnMode">
<option selected="selected">透明传输</option>
<option>MAC保护</option>
<option>数据加密+MAC保护</option>
</select>
</td>
</tr>
<tr>
<th align="right" scope="row" style="color:black">
只读时需要认证的密钥:
</th>
<td align="left">
<select style="color:blue;width:85px" name="ComboxReadFileKey" id="ComboxReadFileKey">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option selected="selected">无需密钥</option>
<option>禁止</option>
</select>
</td>
<td align="right">
只写时需要认证的密钥:
</td>
<td align="left">
<select style="color:blue;width:85px" name="ComboxWriteFileKey" id="ComboxWriteFileKey">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option selected="selected">无需密钥</option>
<option>禁止</option>
</select>
</td>
</tr>
<tr>
<th align="right" scope="row" style="color:black">
读写时需要认证的密钥:
</th>
<td align="left">
<select style="color:blue;width:85px" name="ComboxRWFileKey" id="ComboxRWFileKey">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option selected="selected">无需密钥</option>
<option>禁止</option>
</select>
</td>
<td align="right">
更改配置时需要的密钥:
</td>
<td align="left">
<select style="color:blue;width:85px" name="ComboxEditFileConfigKey" id="ComboxEditFileConfigKey">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option selected="selected">无需密钥</option>
<option>禁止</option>
</select>
</td>
</tr>
</table>
读写起始位:
<input style="color:red;text-align:center;" name="text_rwstar" type="text" id="text_rwstar" value="0" size="8" maxlength="8" />
  读写长度:
<input style="color:red;text-align:center;" name="text_rwsize" type="text" id="text_rwsize" value="30" size="8" maxlength="8" />
  
<input style="width:80px" name="butt_readfile" type="submit" id="butt_readfile" onclick="desfirereaddata()" value="读文件" />
<input style="width:80px" name="butt_writefile" type="submit" id="butt_writefile" onclick="desfirewritedata()" value="写文件" />
<input style="width:80px" name="butt_createdata" type="submit" id="butt_createdata" onclick="createdatastr()" value="生成写数据" /><br>
<textarea style="color:red;width:650px" name="text_dataarea" id="text_dataarea" cols="100" rows="5"></textarea><br>
<input style="width:150px;float:left" name="butt_committransaction" type="submit" id="butt_committransaction" onclick="desfirecommittransaction()" value="提交事务(使备份生效)" />
<input style="width:100px;float:right" name="butt_aborttransaction" type="submit" id="butt_aborttransaction" onclick="desfireaborttransaction()" value="取消事务" />
</td>
</tr>
</table>
<table width="1350" height="100" align="center">
<tr>
<th width="200" height="100" scope="row">
<p>操作提示</p>
<p> </p>
<p> </p>
</th>
<td><textarea style="width:1150px;color:blue;" name="textarea" id="textarea" cols="100" rows="8"></textarea></td>
</tr>
</table>
<p align="center">以上功能需要插件支持,在发送读卡、写卡操作请求之前,请先确保您的电脑已安装并运行我们的读写器插件: <a href="http://www.bossknow.cn:90/RongShiWebReaderTest/RFIDWebPluginSetup_Windows.rar"> RFIDWebPlugin</a> </p>
<p align="center"><a href="http://www.bossknow.cn:90/RongShiWebReaderTest/RFIDWebPluginSetup.html">如何防止RFIDWebPlugin插件被杀毒软件误报删除</a></p>
</body>
</html>