广州荣士IC-02v2免驱动读写器支持Google Chrome 、Microsoft Edge、Firefox火狐、 360、 UC、QQ、搜狗等主流浏览器读写MifareOne卡,只需在客户端运行荣士的RFIDWebServer网页插件,就可以使用JavaScript轻松接入荣士IC-02v2读写器读写M1卡。
网页测试:http://www.bossknow.cn:90/RongShiWebReaderTest/MifareClassICReaderDemo.html
//寻找M1卡并返回卡号
function piccrequest() {
var RequestCardComm = "piccrequest,";
WebSocketRun(RequestCardComm);
}
Case "piccrequest":
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 + M1ErrInfo(strlist[1]);
}
if (strlist.length > 2) {
dispstr = dispstr + "原始16进制卡号:" + strlist[2] + "\r\n";
}
if (strlist.length > 3) {
dispstr = dispstr + "转换08H10D卡号:" + strlist[3] + "\r\n";
}
CardIDShower.value = dispstr;
break;
//轻松读取M1卡扇区内数据
function readcard() {
myctrlword = BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY; //指定控制字,十进制
myareano = 8; //指定为本次读取第8区,十进制
authmode = 1; //指定密码模式,十进制,大于0表示用A密码认证,推荐用A密码认证
mypiccserial = "00000000"; //指定本次操作的卡序列号,十六进制,未知时可指定为8个0
mypicckey = "FFFFFFFFFFFF"; //指定卡片密码,十六进制,FFFFFFFFFFFF为卡片厂家出厂密码
CardIDShower.value = "";
//用parseInt转为十六进制数
var ReadCardComm = "piccreadex," + myctrlword + "," + mypiccserial + "," + myareano + "," + authmode + "," + mypicckey;
WebSocketRun(ReadCardComm);
}
Case "piccreadex":
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 + M1ErrInfo(strlist[1]);
}
if (strlist.length > 2) {
dispstr = dispstr + "卡序列号:" + strlist[2] + "\r\n";
}
if (strlist.length > 3) {
dispstr = dispstr + "卡内数据:" + strlist[3] + "\r\n";
}
CardIDShower.value = dispstr;
break;
//轻松写数据到M1卡扇区内
function writecard() {
myctrlword = BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY; //指定控制字,十进制
myareano = 8; //指定为本次读取第8区,十进制
authmode = 1; //指定密码模式,十进制,大于0表示用A密码认证,推荐用A密码认证
mypiccserial = "00000000"; //指定本次操作的卡序列号,十六进制,未知时可指定为8个0
mypicckey = "FFFFFFFFFFFF"; //指定卡片密码,十六进制,FFFFFFFFFFFF为卡片厂家出厂密码
//指定写卡内容,长度为48个字节,其中每个字节以两个字符表示为十六进制数
piccdata0_2 = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F";
CardIDShower.value = "";
var WriteCardComm = "piccwriteex," + myctrlword + "," + mypiccserial + "," + myareano + "," + authmode + "," + mypicckey + "," + piccdata0_2;
WebSocketRun(WriteCardComm);
}
//复制M1卡卡号
function writecarduid() {
myctrlword = BLOCK0_EN; //指定控制字,十进制
authmode = 1; //指定密码模式,十进制,大于0表示用A密码认证,推荐用A密码认证
mypiccserial = "00000000"; //指定本次操作的卡序列号,十六进制,未知时可指定为8个0
mypicckey = "FFFFFFFFFFFF"; //指定卡片密码,十六进制,FFFFFFFFFFFF为卡片厂家出厂密码
piccdata0 = "12345678000102030405060708090A0B"; //指定写卡内容,长度为16个字节,其中前面四个字节是卡号,第五字节必须为卡号的异或和校验字,后面为厂家标识
CardIDShower.value = "";
var WriteCardComm = "piccwriteserial," + myctrlword + "," + mypiccserial + "," + authmode + "," + mypicckey + "," + piccdata0;
WebSocketRun(WriteCardComm);
}
//修改M1卡AB密码及控制位
function changecardkeyex() {
myctrlword = EXTERNKEY; //指定控制字
myareano = 8; //指定为本次读取第8区
authmode = 1; //批定密码模式,大于0表示用A密码认证,推荐用A密码认证
mypiccserial = "00000000"; //指定本次操作的卡序列号,未知时可指定为8个0
mypicckey_old = "FFFFFFFFFFFF"; //旧密码
mypicckey_new = "ffffffffffffFF078069FFFFFFFFFFFF03";//新密码,其中最前面的FFFFFFFFFFFF为A密码,中间的FF078069为访问控制位,后面的FFFFFFFFFFFF为B密码,03是表示同时更改A、B、密码权限访问字,为02表示密码权限访问字不更改,只改A、B密码,为00表示只改A密码
CardIDShower.value = "";
var ChangeKeyComm = "piccchangesinglekeyex," + myctrlword + "," + mypiccserial + "," + myareano + "," + authmode + "," + mypicckey_old + "," + mypicckey_new;
WebSocketRun(ChangeKeyComm);
}
Case "piccwriteex":
Case "piccchangesinglekeyex":
Case "piccwriteserial":
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 + M1ErrInfo(strlist[1]);
}
if (strlist.length > 2) {
dispstr = dispstr + "卡序列号:" + strlist[2] + "\r\n";
}
CardIDShower.value = dispstr;
break;
|