SOURCE

//定义总方法
trans("41800CC000241311");

function trans(e){
    var otp = e; 
    var newStr = toTwo(otp);
    var str01 = newStr.substring(0,16);
    var str02 = newStr.substring(16);
    console.log(newStr);
    var reg2 = /\d{6}/;
    var reg3 = /\d{8}/;
    console.log(str01);
    console.log(str02);
    var array01 = toArray(str02,reg2,6);
    var array02 = toArray(str01,reg3,8);
//console.log(array01);
//console.log(array02);

    var sixtyArray01 = toSixty(array01); 
    var tenArray01 = toTen(array02);
    sixtyArray01.reverse();
    tenArray01.reverse();
    let OTPID = sixtyArray01.concat(tenArray01);
    console.log(sixtyArray01);
    console.log(tenArray01);
    console.log(OTPID);
}
//定义将原16进制数转化为二进制数字符串
function toTwo(otp){
	var otpArray = [];
    var length = otp.length;
	var index = length/2;
    var reg = /[a-zA-Z0-9]{2}/;
    for(var i = 0;i<index;i++){
        var result = reg.exec(otp);
        result = result.join("");
        otpArray.unshift(result);
        otp = otp.replace(reg,"");
    }
    for(var i in otpArray){
        let result01 = parseInt(otpArray[i],16);
	    result01 = result01.toString(2);
	    otpArray[i] = result01;
        if(otpArray[i].length<8){
            let n = 8-otpArray[i].length;
            for(let j=0;j<n;j++){
                otpArray[i] = "0"+otpArray[i];
            }
        }
    }
     return otpArray.join("")
}

//定义返回二进制数组的方法
function toArray(str,reg,number){
    let index01 = str.length/number;
    var array = [];
    let result02 = "";
    for(var im = 0;im<index01;im++){
	    result02 = reg.exec(str);
	    array.push(result02);
        str = str.replace(reg,"");
    }
     return array;
}

//定义将原二进制数转化为16进制的方法
function toSixty(array){
    var sixtyArray = [];
    for(var i in array){
        array[i] = array[i].join("");
        var a = parseInt(array[i],2);
        sixtyArray.push(a.toString(16));
    }
    return sixtyArray;
}
//定义将原二进制数转化为10进制的方法
function toTen(array){
    for(var i in array){
        array[i] = array[i].join("");
        let temp = parseInt(array[i],2);
        array[i] = temp;
    }
    return array;
   /* array[i].replace(this,parseInt(this,16));
    return array;*/
}
console 命令行工具 X clear

                    
>
console