首页 > 编程语言 >JavaScript读写FM1208 CPU卡源码

JavaScript读写FM1208 CPU卡源码

时间:2023-12-25 21:00:56浏览次数:43  
标签:case ReturnCode FM1208 JavaScript dispstr break 源码 value strlist


JavaScript读写FM1208 CPU卡源码_WEB

本示例使用的发卡器:


<!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>FM1208CPU卡读写DEMO</title>

    <script language="javascript">
        var iswsrun = false;
        var ws;
        var received_msg = "";
        var mytimer;
        var strls = "";
        var errorno = "";

        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 beep() {				 //驱动发卡器响声令
            textarea.value = "";		
            WebSocketRun("pcdbeep,30");					
        }
		
        function getdevicenumber() {         //读取发卡器唯一出厂序号,可以当加密狗使用			
            textarea.value = "";		
            WebSocketRun("pcdgetdevicenumber");			
        }			
		
        function cpu_request() {			//激活发卡器感应区内的CPU卡,获取CPU卡卡号			
            textarea.value = "";	
			carduid.value="";	
            WebSocketRun("cpurequest,");
        }				
		
        function cpu_init() {
            textarea.value = "";
			if (che_clearcard.checked) {   //1表示先将卡片清空再初始化,0表示直接初始化
            	ClearCardYenNo = 1;  
			}else{ClearCardYenNo = 0}
						
            CardKey = cardkey.value.trim();       //16进制的卡密码,卡密码和文件没有任何关系,卡密码只是用来清空卡,读和写文件是无效的。一般不需要修改			
            if (!isHex(CardKey) || CardKey.length!=32) {
				textarea.value = "卡密钥输入错误,请输入正确的32位16进制卡密钥!";
				cardkey.focus();
                cardkey.select();
                return;
			}
			KeyLen = CardKey.length/2;            //卡密码长度
            spacesize = cardspace.value.trim();   //设定本次应用空间大小,单位是字节

            var CpuInitComm = "cpursinit," + ClearCardYenNo + "," + CardKey + "," + KeyLen + "," + spacesize;
            WebSocketRun(CpuInitComm);
        }		

        function cpu_fileadd_s() {
            textarea.value = "";
            FileNo = creatfile.selectedIndex;        //取值范围0-5,创建好的文件不能删除,只能重新初始化卡来清除所有文件
            ReadKey = readkey0.value.trim();         //16进制的只读密码
			if (!isHex(ReadKey) || ReadKey.length!=32) {
				textarea.value = "文件只读密钥输入错误,请输入正确的32位16进制文件只读密钥!";
				readkey0.focus();
                readkey0.select();
                return;
			}
            ReadKeyLen = ReadKey.length/2;           //只读密码长度
            WriteKey = writekey0.value.trim();       //16进制的读写密码
			if (!isHex(WriteKey) || WriteKey.length!=32) {
				textarea.value = "文件读写密钥输入错误,请输入正确的32位16进制文件读写密钥!";
				writekey0.focus();
                writekey0.select();
                return;
			}
            WriteKeyLen = WriteKey.length/2;         //读写密码长度
            spacesize = creatfilesize.value.trim();  //文件空间大小,要小于初始化时定义的空间,单位是字节

            var CpuFileAddComm = "cpursfileadd_s," + FileNo + "," + ReadKey + "," + ReadKeyLen + "," + WriteKey + "," + WriteKeyLen + "," + spacesize;
            WebSocketRun(CpuFileAddComm);
        }

        function cpu_filekeychg() {
            textarea.value = "";

            FileNo = changkeyfile.selectedIndex;            //需要更改密码的文件号,取值范围0-5,						
			var myctrlword =0;
			if (selenewkey.selectedIndex==0){
				myctrlword =0;  							//0 更改CPU卡文件只读密钥
			} else {myctrlword =1;}							//1 更改CPU卡文件读写密钥					
			
			if (changeauthkey.selectedIndex==0){
				myctrlword=myctrlword+0;					//0 用CPU卡文件只读密码认证
			} else {myctrlword=myctrlword+2}				//2 用CPU卡文件读写密钥认证						
			
            OldKey = authkey0.value.trim();    				//16进制的旧密码
			if (!isHex(OldKey) || OldKey.length!=32) {
				textarea.value = "文件认证密钥输入错误,请输入正确的32位16进制文件认证密钥!";
				authkey0.focus();
                authkey0.select();
                return;
			}
            OldKeyLen = OldKey.length/2;                    //旧密码长度			
            NewKey = newkey.value.trim();    				//16进制的新密码
			if (!isHex(NewKey) || NewKey.length!=32) {
				textarea.value = "文件新密钥输入错误,请输入正确的32位16进制文件新密钥!";
				newkey.focus();
                newkey.select();
                return;
			}
            NewKeyLen = NewKey.length/2;                    //新密码长度

            var CpuFileKeyChgComm = "cpursfilekeychg," + FileNo + "," + myctrlword + "," + OldKey + "," + OldKeyLen + "," + NewKey + "," + NewKeyLen;
            WebSocketRun(CpuFileKeyChgComm);
        }
		
        function cpu_filedataread() {
            textarea.value = "";
			rwtext.value="";

            FileNo = rwfile.selectedIndex;                 //需要读取数据的文件号,取值范围0-5,
			if (rwauthmode.selectedIndex==0){
            	myctrlword = 0;                            //OLDKEYR:0 用CPU卡文件只读密码认证,OLDKEYWR:2 用CPU卡文件读写密码认证
			}else {myctrlword = 2;}
			
            FileKey = rwauthkey.value.trim();              //16进制的文件认证密码
			if (!isHex(FileKey) || FileKey.length!=32) {
				textarea.value = "文件认证密钥输入错误,请输入正确的32位16进制文件认证密钥!";
				rwauthkey.focus();
                rwauthkey.select();
                return;
			}
            FileKeyLen = FileKey.length/2;                //密码长度
            DataStart = rwbegin.value.trim();             //读文件的起始地址
            DataLen = rwlen.value.trim();                 //读取数据长度     

            var CpuFileDataReadComm = "cpursfiledataread," + FileNo + "," + myctrlword + "," + FileKey + "," + FileKeyLen + "," + DataStart + "," + DataLen;
            WebSocketRun(CpuFileDataReadComm);
        }		

        function cpu_filedatawrite_s() {
            textarea.value = "";

            FileNo = rwfile.selectedIndex;                  //需要写入数据的文件号,取值范围0-5,
            if (rwauthmode.selectedIndex==0){
            	myctrlword = 0;                            //OLDKEYR:0 用CPU卡文件只读密码认证,OLDKEYWR:2 用CPU卡文件读写密码认证
			}else {myctrlword = 2;}
			
            FileKey = rwauthkey.value.trim();              //16进制的文件认证密码
			if (!isHex(FileKey) || FileKey.length!=32) {
				textarea.value = "文件认证密钥输入错误,请输入正确的32位16进制文件认证密钥!";
				rwauthkey.focus();
                rwauthkey.select();
                return;
			}
            FileKeyLen = FileKey.length/2;                //密码长度
            DataStart = rwbegin.value.trim();             //写文件的起始地址						
            DataInf = rwtext.value.trim();    			  //写入数据     
            if (!isHex(DataInf)) {
                textarea.value =  "写入数据错误\r\n";
				rwtext.focus();
                rwtext.select();
                return;
            }

            var CpuFileDataWriteComm = "cpursfiledatawrite_s," + FileNo + "," + myctrlword + "," + FileKey + "," + FileKeyLen + "," + DataStart + "," + DataInf;						
            WebSocketRun(CpuFileDataWriteComm);
        }
		
        function sendcpuapdu() {
            textarea.value = "";
			
            commstr = apducomm.value.replace(/\s/g, "");  //16进制的指令码
			if (!isHex(commstr) || (commstr.length % 2)!=0) {
				textarea.value = "APDU指令码输入错误,请输入正确的16进制指令码!";
				apducomm.focus();
                apducomm.select();
                return;
			}
			
            var CpuFileDataWriteComm = "cpuisoapdu," + commstr;						
            WebSocketRun(CpuFileDataWriteComm);
        }		

		function calcexauthkey(){
			textarea.value = "";
			resultstr.value="";
			
			randstr = randnum.value.replace(/\s/g, "");  //16进制的随机数
			if (!isHex(randstr) || randstr.length !=8) {
				textarea.value = "随机数输入错误,请输入正确的8位16进制随机数!";
				randnum.focus();
                randnum.select();
                return;
			}
			authkeystr=keystr.value.replace(/\s/g, "");  //16进制的文件认证密钥
			if (!isHex(authkeystr) || authkeystr.length !=32) {
				textarea.value = "认证密钥输入错误,请输入正确的32位16进制认证密钥!";
				keystr.focus();
                keystr.select();
                return;
			}
			WebSocketRun("cpucalcexauthkey,"+randstr+","+authkeystr);
		}

		function changeapdu(){
			switch (seleapdu.selectedIndex) {
				case 0:
					apducomm.value="00 A4 00 00 00";
					break;
				case 1:
					apducomm.value="00 A4 00 00 02 3F 00";
					break;
				case 2:
					apducomm.value="00 84 00 00 04";
					break;
				case 3:
					apducomm.value="00 82 00 00 08 [8字节密文数据(严重声明:如果密码错误多次,返回值从63CX变为63C0时卡将作废)]";
					break;
				case 4:
					apducomm.value="80 0E 00 00 00";
					break;
				case 5:
					apducomm.value="80 E0 00 00 07 3F 00 B0 01 F0 FF FF";
					break;
				case 6:
					apducomm.value="80 D4 01 00 0D 39 F0 F0 AA 55 FF FF FF FF FF FF FF FF";
					break;
				case 7:
					apducomm.value="80 D4 01 00 15 39 F0 F0 AA 55 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF";
					break;
				case 8:
					apducomm.value="80 D4 [不能为01,应输入密码类型,如39或36] 00 0D 39 F0 F0 AA 55 FF FF FF FF FF FF FF FF";
					break;
				case 9:
					apducomm.value="80 D4 [不能为01,应输入密码类型,如39或36] 00 15 39 F0 F0 AA 55 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF";
					break;
				case 10:
					apducomm.value="80 E0 3F 01 0D 38 05 20 F0 F0 95 FF FF 44 44 46 30 31";
					break;
				case 11:
					apducomm.value="80 E0 00 01 07 3F 01 8F 95 F0 FF FF";
					break;
				case 12:
					apducomm.value="80 D4 01 01 0D 3A F0 EF 44 55 12 34 56 78 12 34 56 78";
					break;
				case 13:
					apducomm.value="00 A4 00 00 02 3F 01";
					break;
				case 14:
					apducomm.value="80 E0 00 03 07 28 00 1E F0 F0 FF 01";
					break;
				case 15:
					apducomm.value="00 A4 00 00 02 00 03";
					break;
				case 16:
					apducomm.value="00 D6 00 00 05 01 02 03 04 05";
					break;
				case 17:
					apducomm.value="";
					break;
				case 18:
					apducomm.value="00 B0 00 00 00";
					break;
			}
		}
		
		function DispErrInfo(Errcode){
			var errstr = "";
            switch (Errcode) {
                case "ReturnCode:001":				
                    errstr = ",读写扇区数据失败!";
                    break;
                case "ReturnCode:002":
                    errstr = ",读写1、2块数据失败!";
                    break;
                case "ReturnCode:003":
                    errstr = ",请先激活CPU卡再继续操作!";
                    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:045":
                    errstr = ",此卡不支持更改UID号或UID块已被锁定!";
                    break;
                case "ReturnCode:046":
                    errstr = ",信息过大,标签容量不足!";
                    break;
                case "ReturnCode:050":
                    errstr = ",RATS错误,厂家调试代码,用户不需理会!";
                    break;
                case "ReturnCode:051":
                    errstr = ",PPS错误,厂家调试代码,用户不需理会!";
                    break;
                case "ReturnCode:052":
                    errstr = ",已进入了14443-4协议状态,可进行CPU卡功能所有操作!";
                    break;
                case "ReturnCode:053":
                    errstr = ",未寻到卡,请将卡放到发卡器的感应区!";
                    break;
                case "ReturnCode:054":
                    errstr = ",CPU卡功能通讯错误!";
                    break;
                case "ReturnCode:055":
                    errstr = ",发送ACK指令给卡,让卡接着发送数据回来!";
                    break;
                case "ReturnCode:056":
                    errstr = ",清空根目录失败!";
                    break;
                case "ReturnCode:057":
                    errstr = ",卡片不支持此功能!";
                    break;
                case "ReturnCode:058":
                    errstr = ",卡片初始化失败!";
                    break;
                case "ReturnCode:059":
                    errstr = ",分配的空间不足!";
                    break;
                case "ReturnCode:060":
                    errstr = ",本次操作的实体已存在!";
                    break;
                case "ReturnCode:061":
                    errstr = ",无足够空间!";
                    break;
                case "ReturnCode:062":
                    errstr = ",文件不存在!";
                    break;
                case "ReturnCode:063":
                    errstr = ",权限不足,有可能是用只读密码认证,导致无法更改读写密码或无法写文件!";
                    break;
                case "ReturnCode:064":
                    errstr = ",密码不存在,或密钥文件未创建!";
                    break;
                case "ReturnCode:065":
                    errstr = ",传送长度错误!";
                    break;
                case "ReturnCode:066":
                    errstr = ",接收长度错误,即接收的数据长度指定过大!";
                    break;
                case "ReturnCode:067":
                    errstr = ",功能不支持、或卡中无MF、或卡片已锁定!";
                    break;
                case "ReturnCode:068":
                    errstr = ",密码认证错识次数过多,该密码已被锁死!";
                    break;
                case "ReturnCode:070":
                case "ReturnCode:071":
                case "ReturnCode:072":
                case "ReturnCode:073":
                case "ReturnCode:074":
                case "ReturnCode:075":
                case "ReturnCode:076":
                case "ReturnCode:077":
                case "ReturnCode:078":
                case "ReturnCode:079":
                case "ReturnCode:080":
                case "ReturnCode:081":
                case "ReturnCode:082":
                case "ReturnCode:083":
                case "ReturnCode:084":
                case "ReturnCode:085":
                    var lastnum = errcode.slice(-2) - 70;
                    errstr = ",密码错误,剩余次数为:" + lastnum + ",如剩余次数为0,该密码将锁死,无法再认证!";
                    break;
                case "ReturnCode:086":
                    errstr = ",更改后的密码长度必须和创建时的长度一致!";
                    break;
                case "ReturnCode:087":
                    errstr = ",应用目录不存在!";
                    break;
                case "ReturnCode:088":
                    errstr = ",应用文件不存在!";
                    break;
                case "ReturnCode:089":
                    errstr = ",文件号不能超过 5 !";
                    break;
                case "ReturnCode:090":
                    errstr = ",读取文件时返回的长度不足,数据可能不正确!";
                    break;
                case "ReturnCode:091":
                    errstr = ",一次读文件的长度不能超过255 !";
                    break;
                case "ReturnCode:092":
                    errstr = ",一次写文件的长度不能超过247 !";
                    break;
                case "ReturnCode:444":
                    errstr = ",RFIDWebServer系统文件错误!";
                    break;
                case "ReturnCode:555":
                    errstr = ",未发现有效的NFC标签!";
                    break;					
                default:
                    errstr = ",未知的错误!";
            }
            return errstr;
		}			
		
		
        window.onerror = function (e) {
            alert("不好意思,出错了!");
            return true;//屏蔽系统事件
        }

        function timeoutevent() {
            ws.close();
            textarea.value = "websockket返回超时";
        }

        //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":
                    case "idr_beep":
                        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";
                        }
                        textarea.value = dispstr;
                        break;

                    case "cpurequest":
                        dispstr = "函数名称:" + strlist[0] + "\r\n";
                        if (strlist[1] == "ReturnCode:000" || strlist[1] == "ReturnCode:052") {
                            dispstr = dispstr + "操作结果:" + strlist[1];
                            dispstr = dispstr + ",卡已激活!\r\n";
                            dispstr = dispstr + "16进制卡号:" + strlist[2] + "\r\n";
                            dispstr = dispstr + "10进制卡号:" + strlist[3] + "\r\n";
                            dispstr = dispstr + "卡片参数:" + strlist[4] + "\r\n";
                            dispstr = dispstr + "卡片版本:" + strlist[5] + "\r\n";
                            dispstr = dispstr + "厂家代码:" + strlist[6] + "\r\n";
							carduid.value=strlist[3];
                        } else {
                            dispstr = dispstr + "操作结果:" + strlist[1];
                            dispstr = dispstr + DispErrInfo(strlist[1]);
                        }
                        textarea.value = dispstr;
                        break;

                    case "cpursinit":
                        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 "cpursfileadd_s":
                        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 "cpursfilekeychg":
                        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 "cpursfiledataread":
                        dispstr = "函数名称:" + strlist[0] + "\r\n";
                        if (strlist[1] == "ReturnCode:000") {
                            dispstr = dispstr + "操作结果:" + strlist[1];
                            dispstr = dispstr + ",读文件数据成功!\r\n";
                            //dispstr = dispstr + "卡内数据:" + strlist[2] + "\r\n";
							rwtext.value=strlist[2];
                        } else {
                            dispstr = dispstr + "操作结果:" + strlist[1];
                            dispstr = dispstr + DispErrInfo(strlist[1]);
                        }
                        textarea.value = dispstr;
                        break;

                    case "cpursfiledatawrite_s":
                        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 "cpuisoapdu":
                        dispstr = "函数名称:" + strlist[0] + "\r\n";
                        if (strlist[1] == "ReturnCode:000") {
                            dispstr = dispstr + "操作结果:" + strlist[1];
                            dispstr = dispstr + ",返回数据:"+strlist[2];
                        } else {
                            dispstr = dispstr + "操作结果:" + strlist[1];
                            dispstr = dispstr + DispErrInfo(strlist[1]);
                        }
                        textarea.value = dispstr;
                        break;						

                    case "cpucalcexauthkey":
                        dispstr = "函数名称:" + strlist[0] + "\r\n";
                        if (strlist[1] == "ReturnCode:000") {
                            dispstr = dispstr + "操作结果:" + strlist[1];
                            dispstr = dispstr + ",返回数据:"+strlist[2];
							resultstr.value=strlist[2];
                        } else {
                            dispstr = dispstr + "操作结果:" + strlist[1];
                            dispstr = dispstr + DispErrInfo(strlist[1]);
                        }
                        textarea.value = dispstr;
                        break;						

                    case "cpurscardclr":
                        dispstr = "函数名称:" + strlist[0] + "\r\n";
                        if (strlist[1] == "ReturnCode:000") {
                            dispstr = dispstr + "操作结果:" + strlist[1];
                            dispstr = dispstr + ",强制清空卡成功!\r\n";
                        } else {
                            if (strlist[1] == "ReturnCode:064") {
                                dispstr = dispstr + "操作结果:" + strlist[1];
                                dispstr = dispstr + ",此卡未经过cpursinit函数成功初始化!\r\n";
                            }
                            else {
                                dispstr = dispstr + "操作结果:" + strlist[1];
                                dispstr = dispstr + DispErrInfo(strlist[1]);
                            }
                        }
                        textarea.value = dispstr;
                        break;
                }
            }
        }		
		
        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的浏览器!";
                    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.icmcu.com/ICID15693-02V2test/RFIDWebServerSetup.exe", "top");//打开新窗口

                        alert("请先下载>安装>运行我们的服务程序,再刷新本页面......");
                    }
                };
            }
            catch (ex) {
                if (iswsrun != true) {
                    received_msg = "请先在当前电脑下载>安装>运行我们的服务程序......";
                    window.open("http://www.icmcu.com/ICID15693-02V2test/RFIDWebServerSetup.exe", "top");//打开新窗口

                    alert("请先下载>安装>运行我们的服务程序,再刷新本页面......");
                }
            }
        }
				
	</script>
</head>

<body>
<table width="1100" height="678" border="1" align="center">
  <tr>
    <th width="128" height="45" scope="row"><input name="butt_beep" type="submit" id="butt_beep" onclick="beep()" value="驱动发卡器响声" /></th>
    <td width="934"><input name="butt_getdevnum" type="submit" id="butt_getdevnum" onclick="getdevicenumber()" value="读取发卡器唯一出厂序列号" /></td>
  </tr>
  <tr>
    <th height="47" scope="row"><input name="butt_request" type="submit" id="butt_request" onclick="cpu_request()" value="激活CPU卡" /></th>
    <td>卡号:
    <input name="carduid" type="text" id="carduid" size="11" maxlength="10" />
    ,每次卡片重新进入感应区,都必须先激活卡片才能继续以下的操作!</td>
  </tr>
  <tr>
    <th height="52" scope="row"><input name="butt_cpu_init" type="submit" id="butt_cpu_init" onclick="cpu_init()" value="初始化CPU卡" /></th>
    <td><input type="checkbox" name="che_clearcard" id="che_clearcard" />
      选择先将卡片清空再初始化,本次设定可应用的空间大小:
      <input name="cardspace" type="text" id="cardspace" value="1024" size="6" maxlength="6" />
      ,设置卡片密钥:
      <input name="cardkey" type="text" id="cardkey" value="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" size="34" maxlength="32" /></td>
  </tr>
  <tr>
    <th height="89" scope="row"><input name="butt_cpu_fileadd_s" type="submit" id="butt_cpu_fileadd_s" onclick="cpu_fileadd_s()" value="创建易写文件" /></th>
    <td><p>文件号:
      <select name="creatfile" id="creatfile">
        <option>1号文件</option>
        <option>2号文件</option>
        <option>3号文件</option>
        <option>4号文件</option>
        <option>5号文件</option>
        <option>6号文件</option>
      </select>
    ,16进制只读密钥:
    <input name="readkey0" type="text" id="readkey0" value="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" size="34" maxlength="32" />
    </p>
    <p>文件大小:
      <input name="creatfilesize" type="text" id="creatfilesize" value="256" size="5" maxlength="5" />
    ,16进制读写密钥:
    <label for="writekey0"></label>
    <input name="writekey0" type="text" id="writekey0" value="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" size="34" maxlength="32" />
    </p></td>
  </tr>
  <tr>
    <th height="76" scope="row"><input name="butt_cpu_filekeychg" type="submit" id="butt_cpu_filekeychg" onclick="cpu_filekeychg()" value="修改文件密钥" /></th>
    <td><p>文件号:
      <select name="changkeyfile" id="changkeyfile">
        <option>1号文件</option>
        <option>2号文件</option>
        <option>3号文件</option>
        <option>4号文件</option>
        <option>5号文件</option>
        <option>6号文件</option>
      </select>
      <label for="changeauthkey"></label>
      <select name="changeauthkey" id="changeauthkey">
        <option>用只读密钥认证</option>
        <option selected="selected">用读写密钥认证</option>
      </select>
      <label for="newkey"></label>
      <select name="selenewkey" id="selenewkey">
        <option>修改只读密钥</option>
        <option>修改读写密钥</option>
      </select>
    ,文件认证密钥:
    <label for="authkey0"></label>
    <input name="authkey0" type="text" id="authkey0" value="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" size="34" maxlength="32" />
    </p>
    <p>新密钥:
      <label for="newkey"></label>
      <input name="newkey" type="text" id="newkey" value="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" size="34" maxlength="32" />
    </p></td>
  </tr>
  <tr>
    <th height="110" scope="row"><p>
      <input name="butt_readfile" type="submit" id="butt_readfile" onclick="cpu_filedataread()" value="从文件内读取数据" />
      </p>
<input name="butt_writefile_s" type="submit" id="butt_writefile_s" onclick="cpu_filedatawrite_s()" value="写数据到易写文件" /></th>
    <td><p>文件号:
        <select name="rwfile" id="rwfile">
          <option>1号文件</option>
          <option>2号文件</option>
          <option>3号文件</option>
          <option>4号文件</option>
          <option>5号文件</option>
          <option>6号文件</option>
        </select>
        <select name="rwauthmode" id="rwauthmode">
          <option>用只读密钥认证</option>
          <option selected="selected">用读写密钥认证</option>
        </select>
      ,起始位置:
      <label for="rwbegin"></label>
    <input name="rwbegin" type="text" id="rwbegin" value="0" size="5" maxlength="4" />
    ,长度:
    <label for="rwlen"></label>
    <input name="rwlen" type="text" id="rwlen" value="10" size="4" maxlength="3" />
    ,密钥:
    <label for="rwauthkey"></label>
    <input name="rwauthkey" type="text" id="rwauthkey" value="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" size="34" maxlength="32" />
    </p>
    <p>
      <label for="rwtext"></label>
      <textarea name="rwtext" id="rwtext" cols="130" rows="4"></textarea>
    </p></td>
  </tr>
  <tr>
    <th height="57" scope="row"><input name="butt_sendapdu" type="submit" id="butt_sendapdu" onclick="sendcpuapdu()" value="发送APDU调试指令" /></th>
    <td><select name="seleapdu" id="seleapdu" onchange="changeapdu()">
      <option selected="selected">选择 MF 下的根目录</option>	
      <option>选择 MF 下的根目录(从子目录下返回)</option>
      <option>取 4 个字节的随机数</option>
      <option>外部认证(如密码错误多次卡将作废)</option>
      <option>擦除 当前目录下的所有文件</option>
      <option>建立 当前目录下的密钥文件</option>
      <option>密钥文件建好后给其增加8字节密钥</option>
      <option>密钥文件建好后给其增加16字节密钥</option>
      <option>修改8字节密钥</option>
      <option>修改16字节密钥</option>
      <option>建立目录文件 DF</option>
      <option>建立 DF目录下密钥文件</option>
      <option>在 DF目录下密钥文件里增加口令密钥</option>
      <option>选择 DF 目录</option>
      <option>建立二进制文件</option>
      <option>选择要操作的二进制文件</option>
      <option>写二进制数据进文件</option>
      <option>验证口令密钥</option>
      <option>读出二进制文件</option>
    </select>
    <input name="apducomm" type="text" id="apducomm" value="00 A4 00 00 00" size="90" /></td>
  </tr>
  <tr>
    <th height="59" scope="row"><input name="butt_calcexauthkey" type="submit" id="butt_calcexauthkey" onclick="calcexauthkey()" value="随机数+密钥计算" /></th>
    <td>随机数:
    <input name="randnum" type="text" id="randnum" value="11 22 33 44" size="13" maxlength="11" />
    ,密钥:
    <input name="keystr" type="text" id="keystr" value="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" size="34" maxlength="32" />
    ,计算结果:
    <input name="resultstr" type="text" id="resultstr" size="26" maxlength="24" /></td>
  </tr>
  <tr>
    <th height="121" scope="row"><p>操作提示</p>
    <p> </p>
    <p> </p></th>
    <td><textarea name="textarea" id="textarea" cols="130" rows="8" ></textarea></td>
  </tr>
</table>
</body>
</html>


标签:case,ReturnCode,FM1208,JavaScript,dispstr,break,源码,value,strlist
From: https://blog.51cto.com/RongShi/8972175

相关文章

  • JavaScript读写15693 ICod2 卡源码
    本示例使用设备:<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="......
  • LIMS源码,规范样品化验分析的工作流程,对样品分析的环节进行监控和管理
    LIMS将样品管理、数据管理、资源管理、业务管理、报告管理等功能融为一体,组成一套完整的实验室综合管理和产品质量监控体系。其核心是规范样品化验分析的工作流程,对样品分析的每一个环节进行监控和管理,在提高样品分析质量和人员工作效率的同时,帮助实验室建立起一套完善的质量保证体......
  • 同城代厨做饭预约到家做饭做菜系统家宴app源码厨师入住+厨师端源码
    技术栈:thinkphp+vue后端、uniapp用户端+uniapp厨师端、mysql数据库预约厨师上门做饭系统·常用功能1、预约私厨2、查看订单3、服务评价4、在线支付预约厨师做菜系统·产品优势1、多种行业适配适用多种行业、不同场景。“不止做饭”:系统模式也支持其他类型的同城O2O行业进行管理,......
  • 【练习】爬虫-基础1 - GlidedSky 源码参考!
    网上有很多大佬为了帮助渣渣爬虫提升,都有搭建爬虫练习平台网站,这种网站的好处是可以练习爬取,同时网上也有很多参考教程,尤其适合学习练手使用。爬虫练习网站,镀金的天空-GlidedSky,爬虫-基础1,爬取网页上的数据,计算求和。爬虫-基础1“爬虫的目标很简单,就是拿到想要的数据。这里有一个网......
  • Python 爬虫,gk-design 网站作品信息采集爬虫源码!
    一个比较简单的爬虫源码,爬取gk-design网站作品信息,包括图片及文字内容信息,几乎没有限制,适合新人学习练手使用,文末附上源码供参考学习。小日子的网站随便爬,加大力度,使劲搞,适合Python爬虫新人练手使用和学习,如果你正在找练手网站,不妨尝试爬取下载数据。这里分享几个简单的数据整......
  • Netty源码学习9——从Timer到ScheduledThreadPoolExecutor到HashedWheelTimer
    系列文章目录和关于我一丶前言之前在学习netty源码的时候,经常看nettyhash时间轮(HashedWheelTimer)的出现,时间轮作为一种定时调度机制,在jdk中还存在Timer和ScheduledThreadPoolExecutor。那么为什么netty要重复造轮子昵,HashedWheelTimer又是如何实现的,解决了什么问题?这一篇将从T......
  • JavaScript(JS) 数组
    ​ JavaScript数组是一个可变长度的对象,用于存储多个值。数组的值可以是任何类型,包括数字、字符串、对象、函数等。参考文档:JavaScript(JS)数组-CJavaPy1、创建数组可以使用以下方式创建数组:使用方括号[]来创建一个空数组:JavaScriptconstarr=[]; 使用 A......
  • 【资源汇总】TiDB-TiCDC 源码解读系列最全资源!!!
    作者:Billmay表妹TiCDC是什么?TiCDC(TiDBChangeDataCapture)是用来捕捉和输出TiDB/TiKV集群上数据变更的一个工具。它既可以作为TiDB增量数据同步工具,将TiDB集群的增量数据同步至下游数据库,也提供开放数据协议,支持把数据发布到第三方系统。还记得在社区的唠嗑茶话会中询问......
  • Druid源码阅读--带流程图
    一、架构分析​Druid类图如下所示:​两大核心类:DruidDataSource和DruidAbstractDataSource​连接有效性check:从连接池中获取连接后会做有效性check,在类中有ValidConnectionChecker接口,对应有不同数据库的实现​异常处理:针对不同的数据库,druid......
  • Druid源码阅读--带设计思想
    一、Druid数据源连接池概念​对于连接来说,建立连接和销毁连接是非常耗时的,因此使用池化思想,将连接放入连接池中,便于复用。​1、Druid中连接的概念​由于将连接放入了连接池,那么就存在两个维度的连接,一个是在连接池中真实的物理连接,一个是应用角度获取到的......