Best Python code snippet using autotest_python
tlv_analyzer.js
Source:tlv_analyzer.js  
1var TLV = {2  Analyze: (tlvstring) => {3    var tlvleft = tlvstring.toUpperCase();4    var tlvdata = [];5    while (tlvleft.length) {6      var nextTag = TLV.Map.taglist.map(t => t.tag).filter(t => tlvleft.startsWith(t)).join();7      if (nextTag.length > 0) {8        var nextTagLength = parseInt(tlvleft.substr(nextTag.length, 2),16);9        var nextTagValue = tlvleft.substr(nextTag.length + 2, nextTagLength * 2)10        var nextTlvPos = nextTag.length + 2 + nextTagLength * 2;11        var nextTlvLength = tlvleft.length - nextTlvPos;12        var decodefunc = TLV.Map.taglist.filter(t => t.tag === nextTag).map(t => t.decode)[0];13        tlvdata.push({14          tag: nextTag,15          name: TLV.Map.taglist.filter(t => t.tag === nextTag).map(t => t.name).join(),16          description: TLV.Map.taglist.filter(t => t.tag === nextTag).map(t => t.description).join(),17          length: nextTagLength,18          value: nextTagValue,19          value_decoded: (decodefunc !== undefined) ? decodefunc(nextTagValue) : "",20          _raw: tlvleft.substr(0,nextTlvPos)21        });22        tlvleft = tlvleft.substr(nextTlvPos, nextTlvLength);23      } else {24        tlvdata.push({25          tag: "unknown",26          name: "unknown",27          description: "unknown",28          length: "unknown",29          value: tlvleft,30          value_decoded: "",31          _raw: tlvleft});32        tlvleft = "";33      }34    };35    36    //add additional explanation37    if (tlvdata.find(t => t.tag === "9F34")) {38      tlvdata.find(t => t.tag === "9F34").value_decoded += TLV.AdditionalAnalyzer.cvm(39        tlvdata.find(t => t.tag === "9F34"),40        tlvdata.find(t => t.tag === "95"),41        tlvdata.find(t => t.tag === "9B"),42        tlvdata.find(t => t.tag === "82"),43      );44    }45    46    //return result47    return tlvdata;48  },49  AdditionalAnalyzer: {50    cvm: (cvm, tvr, tsi, aip) => { //Cardholder Verification Method Result Explanation based on EMV Book4 additional info51      if (cvm === undefined || tvr === undefined || tsi === undefined || aip === undefined) {52        return "";53      }54      cvm = {raw: cvm.value, bytes: cvm.value.match(/.{2}/g), bins: cvm.value.match(/.{2}/g).map(h => TLV.Converter.Hex2Bin(h))};55      tvr = {raw: tvr.value, bytes: tvr.value.match(/.{2}/g), bins: tvr.value.match(/.{2}/g).map(h => TLV.Converter.Hex2Bin(h))};56      tsi = {raw: tsi.value, bytes: tsi.value.match(/.{2}/g), bins: tsi.value.match(/.{2}/g).map(h => TLV.Converter.Hex2Bin(h))};57      aip = {raw: aip.value, bytes: aip.value.match(/.{2}/g), bins: aip.value.match(/.{2}/g).map(h => TLV.Converter.Hex2Bin(h))};58      var cvm_byte1 = cvm.bytes[0];59      var cvm_byte2 = cvm.bytes[1];60      var cvm_byte3 = cvm.bytes[2];61      var tvr_bit3  = tvr.bins[2][5];62      var tvr_bit7  = tvr.bins[2][1];63      var tvr_bit8  = tvr.bins[2][0];64      var tsi_bit7  = tsi.bins[0][1];65      var aip_bit5  = aip.bins[0][3];66      var result = "";67      if   (cvm_byte1 === "3F" && cvm_byte2 === "00" && cvm_byte3 === "00" && tsi_bit7 === "0" && aip_bit5 === "0") {68        result = "The card does not support cardholder verification (AIP bit 5=0)";69      } if (cvm_byte1 === "3F" && cvm_byte2 === "00" && cvm_byte3 === "00" && tsi_bit7 === "0") {70        result = "CVM List is not present or the CVM List has no CVM rules";71      } if (cvm_byte1 === "3F" && cvm_byte2 === "00" && cvm_byte3 === "01" && tvr_bit8 === "1" && tsi_bit7 === "1") {72        result = "No CVM Conditions in CVM List are satisfied or the terminal does not support any of the CVM Codes in CVM List where the CVM Condition was satisfied";73      } if (cvm_byte1 === "3F" && cvm_byte2 === "00" && cvm_byte3 === "01" && tvr_bit8 === "1" && tvr_bit7 === "1" && tsi_bit7 === "1") {74        result = "The terminal does not recognise any of the CVM Codes in CVM List (or the code is RFU) where the CVM Condition was satisfied";75      } if ((cvm_byte1 === "00" || cvm_byte1 === "40") && cvm_byte3 === "01" && tvr_bit8 === "1" && tsi_bit7 === "1") {76        result = "The (last) performed CVM is 'Fail CVM processing'";77      } if (cvm_byte3 === "01" && tvr_bit8 === "1" && tsi_bit7 === "1") {78        result = "The last performed CVM fails";79      } if ((cvm_byte1 === "1E" || cvm_byte1 === "5E") && cvm_byte3 === "00" && tsi_bit7 === "1") {80        result = "The CVM performed is 'Signature'";81      } if ((cvm_byte1 === "02" || cvm_byte1 === "42") && cvm_byte3 === "00" && tvr_bit3 === "1" && tsi_bit7 === "1") {82        result = "The CVM performed is 'Online PIN'";83      } if ((cvm_byte1 === "1F" || cvm_byte1 === "5F") && cvm_byte3 === "02" && tsi_bit7 === "1") {84        result = "The CVM performed is 'No CVM required'";85      } if (cvm_byte3 === "01" && tvr_bit8 === "1" && tsi_bit7 === "1") {86        result = "A CVM is performed and fails with the failure action being 'Go to Next' and then the end of the CVM List is reached without another CVM Condition being satisfied";87      } if ((cvm_byte1 === "03" || cvm_byte1 === "05") && cvm_byte3 === "01" && tvr_bit8 === "1" && tsi_bit7 === "1") {88        result = "The CVM performed is a combination CVM Code, and at least one fails and the failure action is Fail CVM";89      } if ((cvm_byte1 === "03" || cvm_byte1 === "05") && cvm_byte3 === "00" && tsi_bit7 === "1") {90        result = "The CVM performed is a combination CVM Code, and one passes and the result of the other is 'unknown'";91      }92      return (result !== "") 93        ? `<div style="padding: 10px; background:#ecf8ff;font-style: italic">[Additional Translation based on EMV Book 4 - Table 2: Setting of CVM Results, TVR bits and TSI bits following CVM Processing] <b>${result}</b></div>`94        : "";95    },96  },97  Converter: {98    Ascii2String: (str) => str.match(/.{2}/g).map(v => String.fromCharCode(parseInt(v,16))).join(""),99    binaryLookup: (str, lookupTable) => {100      var bytes = str.toUpperCase().match(/.{2}/g);101      var bins = bytes.map(h => TLV.Converter.Hex2Bin(h));102      var result = [];103      for (var byteIndex = 0; byteIndex < lookupTable.length; byteIndex++) {104        var tvrByteMap = lookupTable[byteIndex]105        var byteResult = {byte: bytes[byteIndex], bin: bins[byteIndex], result:[]};106        if (bins[byteIndex] !== undefined) {107          for (var tvrBinaryIndex = 0; tvrBinaryIndex < tvrByteMap.length; tvrBinaryIndex++) {108            var tvrBinMap = tvrByteMap[tvrBinaryIndex];109            var match = tvrBinMap.bin === tvrBinMap.bin.match(/./g).map((v,i) => (v === "x") ? "x" :  bins[byteIndex][i]).join("")110            if (match && tvrBinMap.meaning !== "RFU") {111              byteResult.result.push(tvrBinMap);112            }113          }114        115          result.push(byteResult);116        }117      }118      119      //change it to html;120      return '<table style="border-collapse: collapse;">' + result.map(r => `<tr style="border-bottom: 1px solid #eee;"><td style="border:none; padding: 2px;vertical-align:top;">${r.byte} (${r.bin})</td><td style="border:none; padding: 2px;vertical-align:top;">=></td><td style="border:none; padding: 2px;vertical-align:top;">${(r.result.length) ? r.result.map(tr => `<b>[${tr.bin}]</b> ${tr.meaning}`).join("<br>") : ""}</td></tr>`).join("") + '</table>'121    },122    Hex2Bin: (str) => (parseInt(str, 16).toString(2)).padStart(8, '0'),123    Hex2Dec: (str) => parseInt(str,16),124    iso3166: (str) => TLV.Map.iso3166[parseInt(str)],125    iso4217: (str) => TLV.Map.iso4217[parseInt(str)],126    arc: (str) => TLV.Map.arc[str],127    terminalType: (str) => TLV.Map.terminalType[parseInt(str)],128    serviceCode: (str) => TLV.Map.serviceCode[parseInt(str)],129    posEntryMode: (str) => TLV.Map.posEntryMode[parseInt(str)],130    MaskedPan: (str) => `<a href="https://www.freebinchecker.com/bin-lookup/${str.substr(0,6)}" target="_blank"">BIN Checkerã§ ${str.substr(0,6)}  ãç¢ºèª </a><span style="color:red; font-weight:bold;">ãæ³¨ï¼å¤é¨ãµã¤ãã</span>`,131    tvr: (str) => TLV.Converter.binaryLookup(str, TLV.Map.tvr),132    tsi: (str) => TLV.Converter.binaryLookup(str, TLV.Map.tsi),133    auc: (str) => TLV.Converter.binaryLookup(str, TLV.Map.auc),134    aip: (str) => TLV.Converter.binaryLookup(str, TLV.Map.aip),135    cvm: (str) => TLV.Converter.binaryLookup(str, TLV.Map.cvm),136    cid: (str) => TLV.Converter.binaryLookup(str, TLV.Map.cid),137    iad: (str) => TLV.Converter.binaryLookup(str, TLV.Map.iad),138    terminalCapability: (str) => TLV.Converter.binaryLookup(str, TLV.Map.terminalCapability),139    ttq: (str) => TLV.Converter.binaryLookup(str, TLV.Map.ttq), 140    ctq: (str) => TLV.Converter.binaryLookup(str, TLV.Map.ctq),141    atc: (str) => TLV.Converter.binaryLookup(str, TLV.Map.atc),142    cardDataInputCapability: (str) => TLV.Converter.binaryLookup(str, TLV.Map.cardDataInputCapability),143    cvmCapability_cvmRequired: (str) => TLV.Converter.binaryLookup(str, TLV.Map.cvmCapability_cvmRequired),144    cvmCapability_nocvmRequired: (str) => TLV.Converter.binaryLookup(str, TLV.Map.cvmCapability_nocvmRequired),145    cvmList: (str) => str.match(/.{4}/g).map(s => TLV.Converter.binaryLookup(s, TLV.Map.cvmList)).join("<hr>"),146    dc_ac_type: (str) => TLV.Converter.binaryLookup(str, TLV.Map.dc_ac_type),147    ds_ods_info: (str) => TLV.Converter.binaryLookup(str, TLV.Map.ds_ods_info),148    ds_ods_info_for_reader: (str) => TLV.Converter.binaryLookup(str, TLV.Map.ds_ods_info_for_reader),149    kernelConfiguration: (str) => TLV.Converter.binaryLookup(str, TLV.Map.kernelConfiguration),150    outcomeParameterSet: (str) => TLV.Converter.binaryLookup(str, TLV.Map.outcomeParameterSet),151    contactlessCVR: (str) => TLV.Converter.binaryLookup(str, TLV.Map.contactlessCVR),152    cpr: (str) => TLV.Converter.binaryLookup(str, TLV.Map.cpr),153  },154  Map: {155    taglist: [156      {tag:'06', decode:undefined, name:`Object Identifier (OID)`, description:``},157      {tag:'41', decode:undefined, name:`Country code and national data`, description:``},158      {tag:'42', decode:undefined, name:`Issuer Identification Number (IIN)`, description:`The number that identifies the major industry and the card issuer and that forms the first part of the Primary Account Number (PAN)`},159      {tag:'43', decode:undefined, name:`Card service data`, description:``},160      {tag:'44', decode:undefined, name:`Initial access data`, description:``},161      {tag:'45', decode:undefined, name:`Card issuer's data`, description:``},162      {tag:'46', decode:undefined, name:`Pre-issuing data`, description:``},163      {tag:'47', decode:undefined, name:`Card capabilities`, description:``},164      {tag:'48', decode:undefined, name:`Status information`, description:``},165      {tag:'4D', decode:undefined, name:`Extended header list`, description:``},166      {tag:'4F', decode:undefined, name:`Application Identifier (ADF Name)`, description:`The ADF Name identifies the application as described in [ISO 7816-5]. The AID is made up of the Registered Application Provider Identifier (RID) and the Proprietary Identifier Extension (PIX).`},167      {tag:'50', decode: (str) => TLV.Converter.Ascii2String(str), name:`Application Label`, description:`Mnemonic associated with the AID according to ISO/IEC 7816-5`},168      {tag:'51', decode:undefined, name:`Path`, description:`A path may reference any file. It is a concatenation of file identifiers. The path begins with the identifier of a DF (the MF for an absolute path or the current DF for a relative path) and ends with the identifier of the file itself.`},169      {tag:'52', decode:undefined, name:`Command to perform`, description:``},170      {tag:'53', decode:undefined, name:`Discretionary data, discretionary template`, description:``},171      {tag:'56', decode:(str) => TLV.Converter.Ascii2String(str), name:`Track 1 Data`, description:`Track 1 Data contains the data objects of the track 1 according to [ISO/IEC 7813] Structure B, excluding start sentinel, end sentinel and LRC. The Track 1 Data may be present in the file read using the READ RECORD command during a mag-stripe mode transaction.`},172      {tag:'57', decode:undefined, name:`Track 2 Equivalent Data`, description:`Contains the data objects of the track 2, in accordance with [ISO/IEC 7813], excluding start sentinel, end sentinel, and LRC.`},173      {tag:'58', decode:undefined, name:`Track 3 Equivalent Data`, description:``},174      {tag:'59', decode:undefined, name:`Card expiration date`, description:``},175      {tag:'5A', decode:undefined, name:`Application Primary Account Number (PAN)`, description:`Valid cardholder account number`},176      {tag:'5B', decode:undefined, name:`Name of an individual`, description:``},177      {tag:'5C', decode:undefined, name:`Tag list`, description:``},178      {tag:'5D', decode:undefined, name:`Deleted (see 9D)`, description:``},179      {tag:'5E', decode:undefined, name:`Proprietary login data`, description:``},180      {tag:'5F20', decode:(str) => TLV.Converter.Ascii2String(str), name:`Cardholder Name`, description:`Indicates cardholder name according to ISO 7813`},181      {tag:'5F21', decode:undefined, name:`Track 1, identical to the data coded`, description:``},182      {tag:'5F22', decode:undefined, name:`Track 2, identical to the data coded`, description:``},183      {tag:'5F23', decode:undefined, name:`Track 3, identical to the data coded`, description:``},184      {tag:'5F24', decode:undefined, name:`Application Expiration Date`, description:`Date after which application expires. The date is expressed in the YYMMDD format. For MasterCard applications, if the value of YY ranges from '00' to '49' the date reads 20YYMMDD. If the value of YY ranges from '50' to '99' the date reads 19YYMMDD.`},185      {tag:'5F25', decode:undefined, name:`Application Effective Date`, description:`Date from which the application may be used. The date is expressed in the YYMMDD format. For MasterCard branded applications if the value of YY ranges from '00' to '49' the date reads 20YYMMDD. If the value of YY ranges from '50' to '99', the date reads 19YYMMDD.`},186      {tag:'5F26', decode:undefined, name:`Date, Card Effective`, description:``},187      {tag:'5F27', decode:undefined, name:`Interchange control`, description:``},188      {tag:'5F28', decode: (str) => TLV.Converter.iso3166(str), name:`Issuer Country Code`, description:`Indicates the country of the issuer according to ISO 3166-1`},189      {tag:'5F29', decode:undefined, name:`Interchange profile`, description:``},190      {tag:'5F2A', decode:(str) => TLV.Converter.iso4217(str), name:`Transaction Currency Code`, description:`Indicates the currency code of the transaction according to ISO 4217`},191      {tag:'5F2B', decode:undefined, name:`Date of birth`, description:``},192      {tag:'5F2C', decode:undefined, name:`Cardholder nationality`, description:``},193      {tag:'5F2D', decode:undefined, name:`Language Preference`, description:`1-4 languages stored in order of preference, each represented by 2 alphabetical characters according to ISO 639 Note: EMVCo strongly recommends that cards be personalised with data element '5F2D' coded in lowercase, but that terminals accept the data element whether it is coded in upper or lower case.`},194      {tag:'5F2E', decode:undefined, name:`Cardholder biometric data`, description:``},195      {tag:'5F2F', decode:undefined, name:`PIN usage policy`, description:``},196      {tag:'5F30', decode:(str) => TLV.Converter.serviceCode(str), name:`Service Code`, description:`Service code as defined in ISO/IEC 7813 for Track 1 and Track 2`},197      {tag:'5F32', decode:undefined, name:`Transaction counter`, description:``},198      {tag:'5F33', decode:undefined, name:`Date, Transaction`, description:``},199      {tag:'5F34', decode:undefined, name:`Application Primary Account Number (PAN) Sequence Number (PSN)`, description:`Identifies and differentiates cards with the same Application PAN`},200      {tag:'5F35', decode:undefined, name:`Sex (ISO 5218)`, description:`Representation of human sexes through a language-neutral single-digit code (0 = not known, 1 = male, 2 = female, 9 = not applicable)`},201      {tag:'5F36', decode:undefined, name:`Transaction Currency Exponent`, description:`Identifies the decimal point position from the right of the transaction amount accordin to ISO 4217`},202      {tag:'5F37', decode:undefined, name:`Static internal authentication (one-step)`, description:``},203      {tag:'5F38', decode:undefined, name:`Static internal authentication - first associated data`, description:``},204      {tag:'5F39', decode:undefined, name:`Static internal authentication - second associated data`, description:``},205      {tag:'5F3A', decode:undefined, name:`Dynamic internal authentication`, description:``},206      {tag:'5F3B', decode:undefined, name:`Dynamic external authentication`, description:``},207      {tag:'5F3C', decode:(str) => TLV.Converter.iso4217(str), name:`Transaction Reference Currency Code`, description:`Identifies the common currency used by the terminal`},208      {tag:'5F3D', decode:undefined, name:`Transaction Reference Currency Exponent`, description:`Identifies the decimal point position from the right of the terminal common currency`},209      {tag:'5F40', decode:undefined, name:`Cardholder portrait image`, description:``},210      {tag:'5F41', decode:undefined, name:`Element list`, description:``},211      {tag:'5F42', decode:undefined, name:`Address`, description:``},212      {tag:'5F43', decode:undefined, name:`Cardholder handwritten signature image`, description:``},213      {tag:'5F44', decode:undefined, name:`Application image`, description:``},214      {tag:'5F45', decode:undefined, name:`Display message`, description:``},215      {tag:'5F46', decode:undefined, name:`Timer`, description:``},216      {tag:'5F47', decode:undefined, name:`Message reference`, description:``},217      {tag:'5F48', decode:undefined, name:`Cardholder private key`, description:``},218      {tag:'5F49', decode:undefined, name:`Cardholder public key`, description:``},219      {tag:'5F4A', decode:undefined, name:`Public key of certification authority`, description:``},220      {tag:'5F4B', decode:undefined, name:`Deprecated (see note 2 below)`, description:``},221      {tag:'5F4C', decode:undefined, name:`Certificate holder authorization`, description:``},222      {tag:'5F4D', decode:undefined, name:`Integrated circuit manufacturer identifier`, description:``},223      {tag:'5F4E', decode:undefined, name:`Certificate content`, description:``},224      {tag:'5F50', decode:undefined, name:`Issuer Uniform resource locator (URL)`, description:`The URL provides the location of the Issuer's Library Server on the Internet.`},225      {tag:'5F53', decode:undefined, name:`International Bank Account Number (IBAN)`, description:`Uniquely identifies the account of a customer at a financial institution as defined in ISO 13616.`},226      {tag:'5F54', decode:undefined, name:`Bank Identifier Code (BIC)`, description:`Uniquely identifies a bank as defined in ISO 9362.`},227      {tag:'5F55', decode:undefined, name:`Issuer Country Code (alpha2 format)`, description:`Indicates the country of the issuer as defined in ISO 3166 (using a 2 character alphabetic code)`},228      {tag:'5F56', decode:undefined, name:`Issuer Country Code (alpha3 format)`, description:`Indicates the country of the issuer as defined in ISO 3166 (using a 3 character alphabetic code)`},229      {tag:'5F57', decode:undefined, name:`Account Type`, description:`Indicates the type of account selected on the terminal, coded as specified in Annex G`},230      {tag:'60', decode:undefined, name:`Template, Dynamic Authentication`, description:``},231      {tag:'6080', decode:undefined, name:`Commitment (e.g., a positive number less than the public RSA modulus in use)`, description:``},232      {tag:'6081', decode:undefined, name:`Challenge (e.g., a number, possibly zero, less than the public RSA exponent in use)`, description:``},233      {tag:'6082', decode:undefined, name:`Response (e.g., a positive number less than the public RSA modulus in use)`, description:``},234      {tag:'6083', decode:undefined, name:`Committed challenge (e.g., the hash-code of a commitment data object)`, description:``},235      {tag:'6084', decode:undefined, name:`Authentication code (e.g., the hash-code of one or more data fields and a commitment data object)`, description:``},236      {tag:'6085', decode:undefined, name:`Exponential (e.g., a public positive number for establishing a session key by a DH method)`, description:``},237      {tag:'60A0', decode:undefined, name:`Template, Identification data`, description:``},238      {tag:'61', decode:undefined, name:`Application Template`, description:`Template containing one or more data objects relevant to an application directory entry according to [ISO 7816-5].`},239      {tag:'62', decode:undefined, name:`File Control Parameters (FCP) Template`, description:`Identifies the FCP template according to ISO/IEC 7816-4`},240      {tag:'6280', decode:undefined, name:`Number of data bytes in the file, excluding structural information`, description:``},241      {tag:'6281', decode:undefined, name:`Number of data bytes in the file, including structural information if any`, description:``},242      {tag:'6282', decode:undefined, name:`File descriptor byte`, description:``},243      {tag:'6283', decode:undefined, name:`File identifier`, description:``},244      {tag:'6284', decode:undefined, name:`DF name`, description:``},245      {tag:'6285', decode:undefined, name:`Proprietary information, primitive encoding (i.e., not coded in BER-TLV)`, description:``},246      {tag:'6286', decode:undefined, name:`Security attribute in proprietary format`, description:``},247      {tag:'6287', decode:undefined, name:`Identifier of an EF containing an extension of the file control information`, description:``},248      {tag:'6288', decode:undefined, name:`Short EF identifier`, description:``},249      {tag:'628A', decode:undefined, name:`Life cycle status byte (LCS)`, description:``},250      {tag:'628B', decode:undefined, name:`Security attribute referencing the expanded format`, description:``},251      {tag:'628C', decode:undefined, name:`Security attribute in compact format`, description:``},252      {tag:'628D', decode:undefined, name:`Identifier of an EF containing security environment templates`, description:``},253      {tag:'62A0', decode:undefined, name:`Template, Security attribute for data objects`, description:``},254      {tag:'62A1', decode:undefined, name:`Template, Security attribute for physical interfaces`, description:``},255      {tag:'62A2', decode:undefined, name:`One or more pairs of data objects, short EF identifier (tag 88) - absolute or relative path (tag 51)`, description:``},256      {tag:'62A5', decode:undefined, name:`Proprietary information, constructed encoding`, description:``},257      {tag:'62AB', decode:undefined, name:`Security attribute in expanded format`, description:``},258      {tag:'62AC', decode:undefined, name:`Identifier of a cryptographic mechanism`, description:``},259      {tag:'63', decode:undefined, name:`Wrapper`, description:``},260      {tag:'64', decode:undefined, name:`Template, File Management Data (FMD)`, description:``},261      {tag:'65', decode:undefined, name:`Cardholder related data`, description:``},262      {tag:'66', decode:undefined, name:`Template, Card data`, description:``},263      {tag:'67', decode:undefined, name:`Template, Authentication data`, description:``},264      {tag:'68', decode:undefined, name:`Special user requirements`, description:``},265      {tag:'6A', decode:undefined, name:`Template, Login`, description:``},266      {tag:'6A80', decode:undefined, name:`Qualifier`, description:``},267      {tag:'6A81', decode:undefined, name:`Telephone Number`, description:``},268      {tag:'6A82', decode:undefined, name:`Text`, description:``},269      {tag:'6A83', decode:undefined, name:`Delay indicators, for detecting an end of message`, description:``},270      {tag:'6A84', decode:undefined, name:`Delay indicators, for detecting an absence of response`, description:``},271      {tag:'6B', decode:undefined, name:`Template, Qualified name`, description:``},272      {tag:'6B06', decode:undefined, name:`Qualified name`, description:``},273      {tag:'6B80', decode:undefined, name:`Name`, description:``},274      {tag:'6BA0', decode:undefined, name:`Name`, description:``},275      {tag:'6C', decode:undefined, name:`Template, Cardholder image`, description:``},276      {tag:'6D', decode:undefined, name:`Template, Application image`, description:``},277      {tag:'6E', decode:undefined, name:`Application related data`, description:``},278      {tag:'6F', decode:undefined, name:`File Control Information (FCI) Template`, description:`Identifies the FCI template according to ISO/IEC 7816-4`},279      {tag:'6FA5', decode:undefined, name:`Template, FCI A5`, description:``},280      {tag:'70', decode:undefined, name:`READ RECORD Response Message Template`, description:`Template containing the data objects returned by the Card in response to a READ RECORD command. Contains the contents of the record read. (Mandatory for SFIs 1-10. Response messages for SFIs 11-30 are outside the scope of EMV, but may use template '70')`},281      {tag:'71', decode:undefined, name:`Issuer Script Template 1`, description:`Contains proprietary issuer data for transmission to the ICC before the second GENERATE AC command`},282      {tag:'7186', decode:undefined, name:`Issuer Script Command`, description:``},283      {tag:'719F18', decode:undefined, name:`Issuer Script Identifier`, description:``},284      {tag:'72', decode:undefined, name:`Issuer Script Template 2`, description:`Contains proprietary issuer data for transmission to the ICC after the second GENERATE AC command`},285      {tag:'73', decode:undefined, name:`Directory Discretionary Template`, description:`Issuer discretionary part of the directory according to ISO/IEC 7816-5`},286      {tag:'77', decode:undefined, name:`Response Message Template Format 2`, description:`Contains the data objects (with tags and lengths) returned by the ICC in response to a command`},287      {tag:'78', decode:undefined, name:`Compatible Tag Allocation Authority`, description:``},288      {tag:'79', decode:undefined, name:`Coexistent Tag Allocation Authority`, description:``},289      {tag:'7A', decode:undefined, name:`Template, Security Support (SS)`, description:`see 6.4`},290      {tag:'7A80', decode:undefined, name:`Card session counter`, description:``},291      {tag:'7A81', decode:undefined, name:`Session identifier`, description:``},292      {tag:'7A82', decode:undefined, name:`File selection counter`, description:``},293      {tag:'7A83', decode:undefined, name:`File selection counter`, description:``},294      {tag:'7A84', decode:undefined, name:`File selection counter`, description:``},295      {tag:'7A85', decode:undefined, name:`File selection counter`, description:``},296      {tag:'7A86', decode:undefined, name:`File selection counter`, description:``},297      {tag:'7A87', decode:undefined, name:`File selection counter`, description:``},298      {tag:'7A88', decode:undefined, name:`File selection counter`, description:``},299      {tag:'7A89', decode:undefined, name:`File selection counter`, description:``},300      {tag:'7A8A', decode:undefined, name:`File selection counter`, description:``},301      {tag:'7A8B', decode:undefined, name:`File selection counter`, description:``},302      {tag:'7A8C', decode:undefined, name:`File selection counter`, description:``},303      {tag:'7A8D', decode:undefined, name:`File selection counter`, description:``},304      {tag:'7A8E', decode:undefined, name:`File selection counter`, description:``},305      {tag:'7A93', decode:undefined, name:`Digital signature counter`, description:``},306      {tag:'7A9F2X', name:`Internal progression value ('X'-is a specific index, e.g., an index referencing a counter of file selections)`, description:``, decode:undefined},307      {tag:'7A9F3Y', name:`External progression value ('Y'-is a specific index, e.g., an index referencing an external time stamp)`, description:``, decode:undefined},308      {tag:'7B', decode:undefined, name:`Template, Security Environment (SE)`, description:`see 6.5`},309      {tag:'7B80', decode:undefined, name:`SEID byte, mandatory`, description:``},310      {tag:'7B8A', decode:undefined, name:`LCS byte, optional`, description:``},311      {tag:'7BA4', decode:undefined, name:`Control reference template (CRT)`, description:`see 6.3.1`},312      {tag:'7BAA', decode:undefined, name:`Control reference template (CRT)`, description:`see 6.3.1`},313      {tag:'7BAC', decode:undefined, name:`Cryptographic mechanism identifier template, optional`, description:``},314      {tag:'7BB4', decode:undefined, name:`Control reference template (CRT)`, description:`see 6.3.1`},315      {tag:'7BB6', decode:undefined, name:`Control reference template (CRT)`, description:`see 6.3.1`},316      {tag:'7BB8', decode:undefined, name:`Control reference template (CRT)`, description:`see 6.3.1`},317      {tag:'7D', decode:undefined, name:`Template, Secure Messaging (SM)`, description:`see 6`},318      {tag:'7D80', decode:undefined, name:`Plain value not coded in BER-TLV`, description:``},319      {tag:'7D81', decode:undefined, name:`Plain value not coded in BER-TLV`, description:``},320      {tag:'7D82', decode:undefined, name:`Cryptogram (plain value coded in BER-TLV and including secure messaging data objects)`, description:``},321      {tag:'7D83', decode:undefined, name:`Cryptogram (plain value coded in BER-TLV and including secure messaging data objects)`, description:``},322      {tag:'7D84', decode:undefined, name:`Cryptogram (plain value coded in BER-TLV, but not including secure messaging data objects)`, description:``},323      {tag:'7D85', decode:undefined, name:`Cryptogram (plain value coded in BER-TLV, but not including secure messaging data objects)`, description:``},324      {tag:'7D86', decode:undefined, name:`Padding-content indicator byte followed by cryptogram (plain value not coded in BER-TLV)`, description:``},325      {tag:'7D87', decode:undefined, name:`Padding-content indicator byte followed by cryptogram (plain value not coded in BER-TLV)`, description:``},326      {tag:'7D8E', decode:undefined, name:`Cryptographic checksum (at least four bytes)`, description:``},327      {tag:'7D90', decode:undefined, name:`Hash-code`, description:``},328      {tag:'7D91', decode:undefined, name:`Hash-code`, description:``},329      {tag:'7D92', decode:undefined, name:`Certificate (not BER-TLV coded data)`, description:``},330      {tag:'7D93', decode:undefined, name:`Certificate (not BER-TLV coded data)`, description:``},331      {tag:'7D94', decode:undefined, name:`Security environment identifier (SEID byte, see 6.5)`, description:``},332      {tag:'7D95', decode:undefined, name:`Security environment identifier (SEID byte, see 6.5)`, description:``},333      {tag:'7D96', decode:undefined, name:`Number Le in the unsecured command APDU (one or two bytes)`, description:``},334      {tag:'7D97', decode:undefined, name:`Number Le in the unsecured command APDU (one or two bytes)`, description:``},335      {tag:'7D99', decode:undefined, name:`Processing status of the secured response APDU (new SW1-SW2, two bytes)`, description:``},336      {tag:'7D9A', decode:undefined, name:`Input data element for the computation of a digital signature (the value field is signed)`, description:``},337      {tag:'7D9B', decode:undefined, name:`Input data element for the computation of a digital signature (the value field is signed)`, description:``},338      {tag:'7D9C', decode:undefined, name:`Public key`, description:``},339      {tag:'7D9D', decode:undefined, name:`Public key`, description:``},340      {tag:'7D9E', decode:undefined, name:`Digital signature`, description:``},341      {tag:'7DA0', decode:undefined, name:`Input template for the computation of a hash-code (the template is hashed)`, description:``},342      {tag:'7DA1', decode:undefined, name:`Input template for the computation of a hash-code (the template is hashed)`, description:``},343      {tag:'7DA2', decode:undefined, name:`Input template for the verification of a cryptographic checksum (the template is integrated)`, description:``},344      {tag:'7DA4', decode:undefined, name:`Control reference template for authentication (AT)`, description:``},345      {tag:'7DA5', decode:undefined, name:`Control reference template for authentication (AT)`, description:``},346      {tag:'7DA8', decode:undefined, name:`Input template for the verification of a digital signature (the template is signed)`, description:``},347      {tag:'7DAA', decode:undefined, name:`Template, Control reference for hash-code (HT)`, description:``},348      {tag:'7DAB', decode:undefined, name:`Template, Control reference for hash-code (HT)`, description:``},349      {tag:'7DAC', decode:undefined, name:`Input template for the computation of a digital signature (the concatenated value fields are signed)`, description:``},350      {tag:'7DAD', decode:undefined, name:`Input template for the computation of a digital signature (the concatenated value fields are signed)`, description:``},351      {tag:'7DAE', decode:undefined, name:`Input template for the computation of a certificate (the concatenated value fields are certified)`, description:``},352      {tag:'7DAF', decode:undefined, name:`Input template for the computation of a certificate (the concatenated value fields are certified)`, description:``},353      {tag:'7DB0', decode:undefined, name:`Plain value coded in BER-TLV and including secure messaging data objects`, description:``},354      {tag:'7DB1', decode:undefined, name:`Plain value coded in BER-TLV and including secure messaging data objects`, description:``},355      {tag:'7DB2', decode:undefined, name:`Plain value coded in BER-TLV, but not including secure messaging data objects`, description:``},356      {tag:'7DB3', decode:undefined, name:`Plain value coded in BER-TLV, but not including secure messaging data objects`, description:``},357      {tag:'7DB4', decode:undefined, name:`Control reference template for cryptographic checksum (CCT)`, description:``},358      {tag:'7DB5', decode:undefined, name:`Control reference template for cryptographic checksum (CCT)`, description:``},359      {tag:'7DB6', decode:undefined, name:`Control reference template for digital signature (DST)`, description:``},360      {tag:'7DB7', decode:undefined, name:`Control reference template for digital signature (DST)`, description:``},361      {tag:'7DB8', decode:undefined, name:`Control reference template for confidentiality (CT)`, description:``},362      {tag:'7DB9', decode:undefined, name:`Control reference template for confidentiality (CT)`, description:``},363      {tag:'7DBA', decode:undefined, name:`Response descriptor template`, description:``},364      {tag:'7DBB', decode:undefined, name:`Response descriptor template`, description:``},365      {tag:'7DBC', decode:undefined, name:`Input template for the computation of a digital signature (the template is signed)`, description:``},366      {tag:'7DBD', decode:undefined, name:`Input template for the computation of a digital signature (the template is signed)`, description:``},367      {tag:'7DBE', decode:undefined, name:`Input template for the verification of a certificate (the template is certified)`, description:``},368      {tag:'7E', decode:undefined, name:`Template, Nesting Interindustry data objects`, description:``},369      {tag:'7F20', decode:undefined, name:`Display control template`, description:``},370      {tag:'7F21', decode:undefined, name:`Cardholder certificate`, description:``},371      {tag:'7F2E', decode:undefined, name:`Biometric data template`, description:``},372      {tag:'7F49', decode:undefined, name:`Template, Cardholder public key`, description:``},373      {tag:'7F4980', decode:undefined, name:`Algorithm reference as used in control reference data objects for secure messaging`, description:``},374      {tag:'7F4981', decode:undefined, name:`RSA Modulus (a number denoted as n coded on x bytes), or DSA First prime (a number denoted as p coded on y bytes), or ECDSA Prime (a number denoted as p coded on z bytes)`, description:``},375      {tag:'7F4982', decode:undefined, name:`RSA Public exponent (a number denoted as v, e.g., 65537), or DSA Second prime (a number denoted as q dividing p-1, e.g., 20 bytes), or ECDSA First coefficient (a number denoted as a coded on z bytes)`, description:``},376      {tag:'7F4983', decode:undefined, name:`DSA Basis (a number denoted as g of order q coded on y bytes), or ECDSA Second coefficient (a number denoted as b coded on z bytes)`, description:``},377      {tag:'7F4984', decode:undefined, name:`DSA Public key (a number denoted as y equal to g to the power x mod p where x is the private key coded on y bytes), or ECDSA Generator (a point denoted as PB on the curve, coded on 2z bytes)`, description:``},378      {tag:'7F4985', decode:undefined, name:`ECDSA Order (a prime number denoted as q, order of the generator PB, coded on z bytes)`, description:``},379      {tag:'7F4986', decode:undefined, name:`ECDSA Public key (a point denoted as PP on the curve, equal to x times PB where x is the private key, coded on 2z bytes)`, description:``},380      {tag:'7F4C', decode:undefined, name:`Template, Certificate Holder Authorization`, description:``},381      {tag:'7F4E', decode:undefined, name:`Certificate Body`, description:``},382      {tag:'7F4E42', decode:undefined, name:`Certificate Authority Reference`, description:``},383      {tag:'7F4E5F20', decode:undefined, name:`Certificate Holder Reference`, description:``},384      {tag:'7F4E5F24', decode:undefined, name:`Expiration Date, Certificate`, description:``},385      {tag:'7F4E5F25', decode:undefined, name:`Effective Date, Certificate`, description:``},386      {tag:'7F4E5F29', decode:undefined, name:`Certificate Profile Identifier`, description:``},387      {tag:'7F4E65', decode:undefined, name:`Certificate Extensions`, description:``},388      {tag:'7F60', decode:undefined, name:`Template, Biometric information`, description:``},389      {tag:'80', decode:undefined, name:`Response Message Template Format 1`, description:`Contains the data objects (without tags and lengths) returned by the ICC in response to a command`},390      {tag:'81', decode:undefined, name:`Amount, Authorised (Binary)`, description:`Authorised amount of the transaction (excluding adjustments)`},391      {tag:'82', decode:(str) => TLV.Converter.aip(str), name:`Application Interchange Profile (AIP)`, description:`Indicates the capabilities of the card to support specific functions in the application`},392      {tag:'83', decode:undefined, name:`Command Template`, description:`Identifies the data field of a command message`},393      {tag:'84', decode:undefined, name:`Dedicated File (DF) Name`, description:`Identifies the name of the DF as described in ISO/IEC 7816-4`},394      {tag:'86', decode:undefined, name:`Issuer Script Command`, description:`Contains a command for transmission to the ICC`},395      {tag:'87', decode:undefined, name:`Application Priority Indicator`, description:`Indicates the priority of a given application or group of applications in a directory`},396      {tag:'88', decode:undefined, name:`Short File Identifier (SFI)`, description:`Identifies the AEF referenced in commands related to a given ADF or DDF. It is a binary data object having a value in the range 1 to 30 and with the three high order bits set to zero.`},397      {tag:'89', decode:(str) => TLV.Converter.Ascii2String(str), name:`Authorisation Code`, description:`Nonzero value generated by the issuer for an approved transaction.`},398      {tag:'8A', decode:(str) => TLV.Converter.arc(str), name:`Authorisation Response Code (ARC)`, description:`Indicates the transaction disposition of the transaction received from the issuer for online authorisations.\n00, 10, 11 :indicate an issuer approval\n01, 02: indicates an issuer referral\nARC other than above indicates an issuer decline`},399      {tag:'8C', decode:undefined, name:`Card Risk Management Data Object List 1 (CDOL1)`, description:`List of data objects (tag and length) to be passed to the ICC in the first GENERATE AC command`},400      {tag:'8D', decode:undefined, name:`Card Risk Management Data Object List 2 (CDOL2)`, description:`List of data objects (tag and length) to be passed to the ICC in the second GENERATE AC command`},401      {tag:'8E', decode:(str) => TLV.Converter.cvmList(str), name:`Cardholder Verification Method (CVM) List`, description:`Identifies a method of verification of the cardholder supported by the application`},402      {tag:'8F', decode:undefined, name:`Certification Authority Public Key Index (PKI)`, description:`Identifies the certification authority's public key in conjunction with the RID`},403      {tag:'90', decode:undefined, name:`Issuer Public Key Certificate`, description:`Issuer public key certified by a certification authority`},404      {tag:'91', decode:undefined, name:`Issuer Authentication Data`, description:`Data sent to the ICC for online Issuer Authentication`},405      {tag:'92', decode:undefined, name:`Issuer Public Key Remainder`, description:`Remaining digits of the Issuer Public Key Modulus`},406      {tag:'93', decode:undefined, name:`Signed Static Application Data (SAD)`, description:`Digital signature on critical application parameters that is used in static data authentication (SDA).`},407      {tag:'94', decode:undefined, name:`Application File Locator (AFL)`, description:`Indicates the location (SFI range of records) of the Application Elementary Files associated with a particular AID, and read by the Kernel during a transaction.`},408      {tag:'95', decode:(str) => TLV.Converter.tvr(str), name:`Terminal Verification Results (TVR)`, description:`Status of the different functions as seen from the terminal`},409      {tag:'97', decode:undefined, name:`Transaction Certificate Data Object List (TDOL)`, description:`List of data objects (tag and length) to be used by the terminal in generating the TC Hash Value`},410      {tag:'98', decode:undefined, name:`Transaction Certificate (TC) Hash Value`, description:`Result of a hash function specified in Book 2, Annex B3.1`},411      {tag:'99', decode:undefined, name:`Transaction Personal Identification Number (PIN) Data`, description:`Data entered by the cardholder for the purpose of the PIN verification`},412      {tag:'9A', decode:undefined, name:`Transaction Date`, description:`Local date that the transaction was authorised`},413      {tag:'9B', decode:(str) => TLV.Converter.tsi(str), name:`Transaction Status Information (TSI)`, description:`Indicates the functions performed in a transaction`},414      {tag:'9C', decode:undefined, name:`Transaction Type`, description:`Indicates the type of financial transaction, represented by the first two digits of the ISO 8583:1987 Processing Code. The actual values to be used for the Transaction Type data element are defined by the relevant payment system`},415      {tag:'9D', decode:undefined, name:`Directory Definition File (DDF) Name`, description:`Identifies the name of a DF associated with a directory`},416      {tag:'9F01', decode:undefined, name:`Acquirer Identifier`, description:`Uniquely identifies the acquirer within each payment system`},417      {tag:'9F02', decode:undefined, name:`Amount, Authorised (Numeric)`, description:`Authorised amount of the transaction (excluding adjustments)`},418      {tag:'9F03', decode:undefined, name:`Amount, Other (Numeric)`, description:`Secondary amount associated with the transaction representing a cashback amount`},419      {tag:'9F04', decode:undefined, name:`Amount, Other (Binary)`, description:`Secondary amount associated with the transaction representing a cashback amount`},420      {tag:'9F05', decode:undefined, name:`Application Discretionary Data`, description:`Issuer or payment system specified data relating to the application`},421      {tag:'9F06', decode:undefined, name:`Application Identifier (AID), Terminal`, description:`Identifies the application as described in ISO/IEC 7816-5`},422      {tag:'9F07', decode:(str) => TLV.Converter.auc(str), name:`Application Usage Control (AUC)`, description:`Indicates issuer's specified restrictions on the geographic usage and services allowed for the application`},423      {tag:'9F08', decode:undefined, name:`Application Version Number`, description:`Version number assigned by the payment system for the application in the Card`},424      {tag:'9F09', decode:undefined, name:`Application Version Number`, description:`Version number assigned by the payment system for the Kernel application`},425      {tag:'9F0A', decode:undefined, name:`Application Selection Registered Proprietary Data`, description: ''},426      {tag:'9F0B', decode:(str) => TLV.Converter.Ascii2String(str), name:`Cardholder Name - Extended`, description:`Indicates the whole cardholder name when greater than 26 characters using the same coding convention as in ISO 7813`},427      {tag:'9F0D', decode:(str) => TLV.Converter.tvr(str), name:`Issuer Action Code - Default`, description:`Specifies the issuer's conditions that cause a transaction to be rejected if it might have been approved online, but the terminal is unable to process the transaction online`},428      {tag:'9F0E', decode:(str) => TLV.Converter.tvr(str), name:`Issuer Action Code - Denial`, description:`Specifies the issuer's conditions that cause the denial of a transaction without attempt to go online`},429      {tag:'9F0F', decode:(str) => TLV.Converter.tvr(str), name:`Issuer Action Code - Online`, description:`Specifies the issuer's conditions that cause a transaction to be transmitted online`},430      {tag:'9F10', decode:(str) => TLV.Converter.iad(str), name:`Issuer Application Data (IAD)`, description:`Contains proprietary application data for transmission to the issuer in an online transaction. Note: For CCD-compliant applications, Annex C, section C7 defines the specific coding of the Issuer Application Data (IAD). To avoid potential conflicts with CCD-compliant applications, it is strongly recommended that the IAD data element in an application that is not CCD-compliant should not use the coding for a CCD-compliant application.`},431      {tag:'9F11', decode:undefined, name:`Issuer Code Table Index`, description:`Indicates the code table according to ISO/IEC 8859 for displaying the Application Preferred Name`},432      {tag:'9F12', decode:(str) => TLV.Converter.Ascii2String(str), name:`Application Preferred Name`, description:`Preferred mnemonic associated with the AID`},433      {tag:'9F13', decode:undefined, name:`Last Online Application Transaction Counter (ATC) Register`, description:`ATC value of the last transaction that went online`},434      {tag:'9F14', decode:undefined, name:`Lower Consecutive Offline Limit (LCOL)`, description:`Issuer-specified preference for the maximum number of consecutive offline transactions for this ICC application allowed in a terminal with online capability`},435      {tag:'9F15', decode:undefined, name:`Merchant Category Code (MCC)`, description:`Classifies the type of business being done by the merchant, represented according to ISO 8583:1993 for Card Acceptor Business Code`},436      {tag:'9F16', decode:(str) => TLV.Converter.Ascii2String(str), name:`Merchant Identifier`, description:`When concatenated with the Acquirer Identifier, uniquely identifies a given merchant`},437      {tag:'9F17', decode:undefined, name:`Personal Identification Number (PIN) Try Counter`, description:`Number of PIN tries remaining`},438      {tag:'9F18', decode:undefined, name:`Issuer Script Identifier`, description:`May be sent in authorisation response from issuer when response contains Issuer Script. Assigned by the issuer to uniquely identify the Issuer Script.`},439      {tag:'9F19', decode:undefined, name:`Deleted (see 9F49)`, description:``},440      {tag:'9F1A', decode:(str) => TLV.Converter.iso3166(str), name:`Terminal Country Code`, description:`Indicates the country of the terminal, represented according to ISO 3166`},441      {tag:'9F1B', decode:undefined, name:`Terminal Floor Limit`, description:`Indicates the floor limit in the terminal in conjunction with the AID`},442      {tag:'9F1C', decode:(str) => TLV.Converter.Ascii2String(str), name:`Terminal Identification`, description:`Designates the unique location of a Terminal at a merchant`},443      {tag:'9F1D', decode:undefined, name:`Terminal Risk Management Data`, description:`Application-specific value used by the card for risk management purposes`},444      {tag:'9F1E', decode:(str) => TLV.Converter.Ascii2String(str), name:`Interface Device (IFD) Serial Number`, description:`Unique and permanent serial number assigned to the IFD by the manufacturer`},445      {tag:'9F1F', decode:(str) => TLV.Converter.Ascii2String(str), name:`Track 1 Discretionary Data`, description:`Discretionary part of track 1 according to ISO/IEC 7813`},446      {tag:'9F20', decode:undefined, name:`Track 2 Discretionary Data`, description:`Discretionary part of track 2 according to ISO/IEC 7813`},447      {tag:'9F21', decode:undefined, name:`Transaction Time`, description:`Local time at which the transaction was performed.`},448      {tag:'9F22', decode:undefined, name:`Certification Authority Public Key Index (PKI)`, description:`Identifies the Certificate Authority's public key in conjunction with the RID for use in offline static and dynamic data authentication.`},449      {tag:'9F23', decode:undefined, name:`Upper Consecutive Offline Limit (UCOL)`, description:`Issuer-specified preference for the maximum number of consecutive offline transactions for this ICC application allowed in a terminal without online capability`},450      {tag:'9F24', decode:(str) => TLV.Converter.Ascii2String(str), name:`Payment Account Reference (PAR) generated or linked directly to the provision request in the token vault`, description:`Payment Account Reference: EMV contact and contactless chip specifications products may support PAR by assigning a unique EMV tag (9F24) to represent PAR. PAR SHALL be required personalisation data for payment tokens but will be optional for terminals to read and transmit.`},451      {tag:'9F26', decode:undefined, name:`Application Cryptogram (AC)`, description:`Cryptogram returned by the ICC in response of the GENERATE AC or RECOVER AC command`},452      {tag:'9F27', decode:(str) => TLV.Converter.cid(str), name:`Cryptogram Information Data (CID)`, description:`Indicates the type of cryptogram and the actions to be performed by the terminal`},453      {tag:'9F29', decode:undefined, name:`Extended Selection`, description:`The value to be appended to the ADF Name in the data field of the SELECT command, if the Extended Selection Support flag is present and set to 1. Content is payment system proprietary.`},454      {tag:'9F2A', decode:undefined, name:`Kernel Identifier`, description:`Indicates the card's preference for the kernel on which the contactless application can be processed.`},455      {tag:'9F2D', decode:undefined, name:`Integrated Circuit Card (ICC) PIN Encipherment Public Key Certificate`, description:`ICC PIN Encipherment Public Key certified by the issuer`},456      {tag:'9F2E', decode:undefined, name:`Integrated Circuit Card (ICC) PIN Encipherment Public Key Exponent`, description:`ICC PIN Encipherment Public Key Exponent used for PIN encipherment`},457      {tag:'9F2F', decode:undefined, name:`Integrated Circuit Card (ICC) PIN Encipherment Public Key Remainder`, description:`Remaining digits of the ICC PIN Encipherment Public Key Modulus`},458      {tag:'9F32', decode:undefined, name:`Issuer Public Key Exponent`, description:`Issuer public key exponent used for the verification of the Signed Static Application Data and the ICC Public Key Certificate`},459      {tag:'9F33', decode:(str) => TLV.Converter.terminalCapability(str), name:`Terminal Capabilities`, description:`Indicates the card data input, CVM, and security capabilities of the Terminal and Reader. The CVM capability (Byte 2) is instantiated with values depending on the transaction amount. The Terminal Capabilities is coded according to Annex A.2 of [EMV Book 4].`},460      {tag:'9F34', decode:(str) => TLV.Converter.cvm(str), name:`Cardholder Verification Method (CVM) Results`, description:`Indicates the results of the last CVM performed\n[Byte 1] CVM Performed\n[Byte 2] CVM Condition\n[Byte 3] CVM Result`},461      {tag:'9F35', decode:(str) => TLV.Converter.terminalType(str), name:`Terminal Type`, description:`Indicates the environment of the terminal, its communications capability, and its operational control`},462      {tag:'9F36', decode:(str) => TLV.Converter.Hex2Dec(str), name:`Application Transaction Counter (ATC)`, description:`Counter maintained by the application in the ICC (incrementing the ATC is managed by the ICC)`},463      {tag:'9F37', decode:undefined, name:`Unpredictable Number (UN)`, description:`Value to provide variability and uniqueness to the generation of a cryptogram`},464      {tag:'9F38', decode:undefined, name:`Processing Options Data Object List (PDOL)`, description:`Contains a list of terminal resident data objects (tags and lengths) needed by the ICC in processing the GET PROCESSING OPTIONS command`},465      {tag:'9F39', decode:(str) => TLV.Converter.posEntryMode(str), name:`Point-of-Service (POS) Entry Mode`, description:`Indicates the method by which the PAN was entered, according to the first two digits of the ISO 8583:1987 POS Entry Mode`},466      {tag:'9F3A', decode:undefined, name:`Amount, Reference Currency (Binary)`, description:`Authorised amount expressed in the reference currency`},467      {tag:'9F3B', decode:(str) => TLV.Converter.iso4217(str), name:`Currency Code, Application Reference`, description:`1-4 currency codes used between the terminal and the ICC when the Transaction Currency Code is different from the Application Currency Code; each code is 3 digits according to ISO 4217`},468      {tag:'9F3C', decode:(str) => TLV.Converter.iso4217(str), name:`Currency Code, Transaction Reference`, description:`Code defining the common currency used by the terminal in case the Transaction Currency Code is different from the Application Currency Code`},469      {tag:'9F3D', decode:undefined, name:`Currency Exponent, Transaction Reference`, description:`Indicates the implied position of the decimal point from the right of the transaction amount, with the Transaction Reference Currency Code represented according to ISO 4217`},470      {tag:'9F40', decode:(str) => TLV.Converter.atc(str), name:`Additional Terminal Capabilities (ATC)`, description:`Indicates the data input and output capabilities of the Terminal and Reader. The Additional Terminal Capabilities is coded according to Annex A.3 of [EMV Book 4].`},471      {tag:'9F41', decode:undefined, name:`Transaction Sequence Counter`, description:`Counter maintained by the terminal that is incremented by one for each transaction`},472      {tag:'9F42', decode:(str) => TLV.Converter.iso4217(str), name:`Currency Code, Application`, description:`Indicates the currency in which the account is managed according to ISO 4217`},473      {tag:'9F43', decode:undefined, name:`Currency Exponent, Application Reference`, description:`Indicates the implied position of the decimal point from the right of the amount, for each of the 1-4 reference currencies represented according to ISO 4217`},474      {tag:'9F44', decode:undefined, name:`Currency Exponent, Application`, description:`Indicates the implied position of the decimal point from the right of the amount represented according to ISO 4217`},475      {tag:'9F45', decode:undefined, name:`Data Authentication Code`, description:`An issuer assigned value that is retained by the terminal during the verification process of the Signed Static Application Data`},476      {tag:'9F46', decode:undefined, name:`Integrated Circuit Card (ICC) Public Key Certificate`, description:`ICC Public Key certified by the issuer`},477      {tag:'9F47', decode:undefined, name:`Integrated Circuit Card (ICC) Public Key Exponent`, description:`Exponent ICC Public Key Exponent used for the verification of the Signed Dynamic Application Data`},478      {tag:'9F48', decode:undefined, name:`Integrated Circuit Card (ICC) Public Key Remainder`, description:`Remaining digits of the ICC Public Key Modulus`},479      {tag:'9F49', decode:undefined, name:`Dynamic Data Authentication Data Object List (DDOL)`, description:`List of data objects (tag and length) to be passed to the ICC in the INTERNAL AUTHENTICATE command`},480      {tag:'9F4A', decode:undefined, name:`Static Data Authentication Tag List (SDA)`, description:`List of tags of primitive data objects defined in this specification whose value fields are to be included in the Signed Static or Dynamic Application Data`},481      {tag:'9F4B', decode:undefined, name:`Signed Dynamic Application Data (SDAD)`, description:`Digital signature on critical application parameters for CDA`},482      {tag:'9F4C', decode:undefined, name:`ICC Dynamic Number`, description:`Time-variant number generated by the ICC, to be captured by the terminal`},483      {tag:'9F4D', decode:undefined, name:`Log Entry`, description:`Provides the SFI of the Transaction Log file and its number of records`},484      {tag:'9F4E', decode:(str) => TLV.Converter.Ascii2String(str), name:`Merchant Name and Location`, description:`Indicates the name and location of the merchant`},485      {tag:'9F4F', decode:undefined, name:`Log Format`, description:`List (in tag and length format) of data objects representing the logged data elements that are passed to the terminal when a transaction log record is read`},486      {tag:'9F50', decode:undefined, name:`Offline Accumulator Balance`, description:`Represents the amount of offline spending available in the Card. The Offline Accumulator Balance is retrievable by the GET DATA command, if allowed by the Card configuration.`},487      {tag:'9F51', decode:(str) => TLV.Converter.iso4217(str), name:`Application Currency Code`, description:``},488      {tag:'9F52', decode:undefined, name:`Application Default Action (ADA)`, description:``},489      {tag:'9F53', decode:(str) => TLV.Converter.contactlessCVR(str), name:`Contactless Card Verification Results`, description:`The Contactless CVR is used with Card Risk Management-Card Action Codes (CRM-CACs) and Card Verification Method-Card Action Code (CVM-CACs) during Card Action Analysis. This data element allows the Contactless application to determine the acceptable risk for processing the:\n⢠Transaction over the contactless interface,\n⢠Transaction offline, or\n⢠Transaction with no cardholder verification.\nThe Contactless CVR is transmitted to the Issuer as part of Issuer Application Data (tagâ9F10â).`},490      {tag:'9F54', decode:undefined, name:`Cumulative Total Transaction Amount Limit (CTTAL)`, description:``},491      {tag:'9F55', decode:undefined, name:`Geographic Indicator`, description:``},492      {tag:'9F56', decode:undefined, name:`Issuer Authentication Indicator`, description:``},493      {tag:'9F57', decode:(str) => TLV.Converter.iso3166(str), name:`Issuer Country Code`, description:``},494      {tag:'9F58', decode:undefined, name:`Consecutive Transaction Counter Limit (CTCL)`, description:``},495      {tag:'9F59', decode:undefined, name:`Consecutive Transaction Counter Upper Limit (CTCUL)`, description:``},496      {tag:'9F5A', decode:undefined, name:`Application Program Identifier (Program ID)`, description:`Payment system proprietary data element identifying the Application Program ID of the card application. When personalised, the Application Program ID is returned in the FCI Issuer Discretionary Data of the SELECT response (Tag âBF0C'). EMV mode readers that support Dynamic Reader Limits (DRL) functionality examine the Application Program ID to determine the Reader Limit Set to apply.`},497      {tag:'9F5B', decode:undefined, name:`Issuer Script Results`, description:`Indicates the results of Issuer Script processing. When the reader/terminal transmits this data element to the acquirer, in this version of Kernel 3, it is acceptable that only byte 1 is transmitted, although it is preferable for all five bytes to be transmitted.`},498      {tag:'9F5C', decode:undefined, name:`Cumulative Total Transaction Amount Upper Limit (CTTAUL)`, description:`Visa proprietary data element specifying the maximum total amount of offline transactions in the designated currency or designated and secondary currency allowed for the card application before a transaction is declined after an online transaction is unable to be performed.`},499      {tag:'9F5D', decode:undefined, name:`Available Offline Spending Amount (AOSA)`, description:`Kernel 3 proprietary data element indicating the remaining amount available to be spent offline. The AOSA is a calculated field used to allow the reader to print or display the amount of offline spend that is available on the card.`},500      {tag:'9F5E', decode:undefined, name:`Consecutive Transaction International Upper Limit (CTIUL)`, description:``},501      {tag:'9F5F', decode:undefined, name:`DS Slot Availability`, description:`Contains the Card indication, obtained in the response to the GET PROCESSING OPTIONS command, about the slot type(s) available for data storage.`},502      {tag:'9F60', decode:undefined, name:`CVC3 (Track1)`, description:`The CVC3 (Track1) is a 2-byte cryptogram returned by the Card in the response to the COMPUTE CRYPTOGRAPHIC CHECKSUM command.`},503      {tag:'9F61', decode:undefined, name:`CVC3 (Track2)`, description:`The CVC3 (Track2) is a 2-byte cryptogram returned by the Card in the response to the COMPUTE CRYPTOGRAPHIC CHECKSUM command.`},504      {tag:'9F62', decode:undefined, name:`PCVC3 (Track1)`, description:`PCVC3(Track1) indicates to the Kernel the positions in the discretionary data field of the Track 1 Data where the CVC3 (Track1) digits must be copied.`},505      {tag:'9F63', decode:undefined, name:`Offline Counter Initial Value`, description:``},506      {tag:'9F64', decode:undefined, name:`NATC (Track1)`, description:`The value of NATC(Track1) represents the number of digits of the Application Transaction Counter to be included in the discretionary data field of Track 1 Data.`},507      {tag:'9F65', decode:undefined, name:`PCVC3 (Track2)`, description:`PCVC3(Track2) indicates to the Kernel the positions in the discretionary data field of the Track 2 Data where the CVC3 (Track2) digits must be copied.`},508      {tag:'9F66', decode:(str) => TLV.Converter.ttq(str), name:`Terminal Transaction Qualifiers (TTQ)`, description:`Indicates reader capabilities, requirements, and preferences to the card. TTQ byte 2 bits 8-7 are transient values, and reset to zero at the beginning of the transaction. All other TTQ bits are static values, and not modified based on transaction conditions. TTQ byte 3 bit 7 shall be set by the acquirer-merchant to 1b.`},509      {tag:'9F67', decode:undefined, name:`MSD Offset`, description:``},510      {tag:'9F68', decode:undefined, name:`Card Additional Processes`, description:``},511      {tag:'9F69', decode:undefined, name:`Card Authentication Related Data`, description:`Contains the fDDA Version Number, Card Unpredictable Number, and Card Transaction Qualifiers. For transactions where fDDA is performed, the Card Authentication Related Data is returned in the last record specified by the Application File Locator for that transaction.`},512      {tag:'9F6A', decode:undefined, name:`Unpredictable Number (Numeric)`, description:`Unpredictable number generated by the Kernel during a mag-stripe mode transaction. The Unpredictable Number (Numeric) is passed to the Card in the data field of the COMPUTE CRYPTOGRAPHIC CHECKSUM command. The 8-nUN most significant digits must be set to zero.`},513      {tag:'9F6B', decode:undefined, name:`Card CVM Limit`, description:``},514      {tag:'9F6C', decode:(str) => TLV.Converter.ctq(str), name:`Card Transaction Qualifiers (CTQ)`, description:`In this version of the specification, used to indicate to the device the card CVM requirements, issuer preferences, and card capabilities.`},515      {tag:'9F6D', decode:undefined, name:`VLP Reset Threshold`, description:``},516      {tag:'9F6E', decode:undefined, name:`Third Party Data`, description:`The Third Party Data contains various information, possibly including information from a third party. If present in the Card, the Third Party Data must be returned in a file read using the READ RECORD command or in the File Control Information Template. 'Device Type' is present when the most significant bit of byte 1 of 'Unique Identifier' is set to 0b. In this case, the maximum length of 'Proprietary Data' is 26 bytes. Otherwise it is 28 bytes.`},517      {tag:'9F6F', decode:undefined, name:`DS Slot Management Control`, description:`Contains the Card indication, obtained in the response to the GET PROCESSING OPTIONS command, about the status of the slot containing data associated to the DS Requested Operator ID.`},518      {tag:'9F70', decode:undefined, name:`Protected Data Envelope 1`, description:`The Protected Data Envelopes contain proprietary information from the issuer, payment system or third party. The Protected Data Envelope can be retrieved with the GET DATA command. Updating the Protected Data Envelope with the PUT DATA command requires secure messaging and is outside the scope of this specification.`},519      {tag:'9F71', decode:(str) => TLV.Converter.cpr(str), name:`Card Processing Requirements.`, description: `This is a Contactless Kernel 6 applicationproprietary data element used by the card to communicate the card processing requirements for the transaction and the card capabilities to the reader.The Kernelmay perform Cardholder verification based onthe reader configuration and card request. The CVMs supported by the Kernelare:\n- Online PIN,\n- Signature,\n- No CVM, and\n- For mobile only: Consumer Device CVM (CD CVM) -a CVM performed on, and validated by, the consumerâs payment device, independent of the reader.\n\n--------------------\nAdditional Info from Book C-6 Section 3.5\nOnline PIN, signature and confirmation code are not allowed. \nThe Kernel shall check if Card Processing Requirement (CPR) Encoding CPR B2b1 = â1â (CVM Fallback to No CVM allowed) and Terminal Capabilities (â9F33â) B2b4 is set to â1â (No CVM Required).\nIf yes, then The Kernel shall request âNo CVMâin the CVM outcome parameter and approvethe CVM.(End Card Verification Method process.  Go to the next transaction stepin the process.)\n\nIf not, then Kernel shall check if the terminal supports another interface: \n1) If the Kernel does not support another interface, the Kernel shall ask for another card and sends âEnd Applicationâ(for Processing Error)Outcome; \n2) ELSE the Kernel shall send âTry Another Interfaceâ as Outcome.`},520      {tag:'9F72', decode:undefined, name:`Protected Data Envelope 3`, description:`Same as Protected Data Envelope 1.`},521      {tag:'9F73', decode:undefined, name:`Protected Data Envelope 4`, description:`Same as Protected Data Envelope 1.`},522      {tag:'9F74', decode:undefined, name:`Protected Data Envelope 5`, description:`Same as Protected Data Envelope 1.`},523      {tag:'9F75', decode:undefined, name:`Unprotected Data Envelope 1`, description:`The Unprotected Data Envelopes contain proprietary information from the issuer, payment system or third party. Unprotected Data Envelopes can be retrieved with the GET DATA command and can be updated with the PUT DATA (CLA='80') command without secure messaging.`},524      {tag:'9F76', decode:undefined, name:`Unprotected Data Envelope 2`, description:`Same as Unprotected Data Envelope 1.`},525      {tag:'9F77', decode:undefined, name:`Unprotected Data Envelope 3`, description:`Same as Unprotected Data Envelope 1.`},526      {tag:'9F78', decode:undefined, name:`Unprotected Data Envelope 4`, description:`Same as Unprotected Data Envelope 1.`},527      {tag:'9F79', decode:undefined, name:`Unprotected Data Envelope 5`, description:`Same as Unprotected Data Envelope 1.`},528      {tag:'9F7A', decode:undefined, name:`VLP Terminal Support Indicator`, description:`If present indicates offline and/or online support. If absent indicates online only support`},529      {tag:'9F7B', decode:undefined, name:`VLP Terminal Transaction Limit`, description:``},530      {tag:'9F7C', decode:undefined, name:`Customer Exclusive Data (CED)`, description:`Contains data for transmission to the issuer.`},531      {tag:'9F7D', decode:undefined, name:`DS Summary 1`, description:`Contains the Card indication, obtained in the response to the GET PROCESSING OPTIONS command, about either the stored summary associated with DS ODS Card if present, or about a default zero-filled summary if DS ODS Card is not present and DS Unpredictable Number is present.`},532      {tag:'9F7E', decode:undefined, name:`Mobile Support Indicator`, description:`The Mobile Support Indicator informs the Card that the Kernel supports extensions for mobile and requires on device cardholder verification.`},533      {tag:'9F7F', decode:undefined, name:`DS Unpredictable Number`, description:`Contains the Card challenge (random), obtained in the response to the GET PROCESSING OPTIONS command, to be used by the Terminal in the summary calculation when providing DS ODS Term.`},534      {tag:'A5', decode:undefined, name:`File Control Information (FCI) Proprietary Template`, description:`Identifies the data object proprietary to this specification in the FCI template according to ISO/IEC 7816-4`},535      {tag:'BF0C', decode:undefined, name:`File Control Information (FCI) Issuer Discretionary Data`, description:`Issuer discretionary part of the File Control Information Proprietary Template.`},536      {tag:'BF50', decode:undefined, name:`Visa Fleet - CDO`, description:``},537      {tag:'BF60', decode:undefined, name:`Integrated Data Storage Record Update Template`, description:`Part of the command data for the EXTENDED GET PROCESSING OPTIONS command. The IDS Record Update Template contains data to be updated in one or more IDS Records.`},538    ],539    arc: {540      '3030': "[00] Approved and completed successfully",541      '3031': "[01] Refer to card issuer",542      '3032': "[02] Refer to card issuer, special condition",543      '3033': "[03] Invalid merchant",544      '3034': "[04] Pick up card (no fraud)",545      '3035': "[05] Do not honor",546      '3036': "[06] Error",547      '3037': "[07] Pick up card, special condition (fraud account)",548      '3130': "[10] Partial approval",549      '3131': "[11] Approved (V.I.P)",550      '3132': "[12] Invalid transaction",551      '3133': "[13] Invalid amount or currency conversion field overflow",552      '3134': "[14] Invalid account number (no such number)",553      '3135': "[15] No such issuer",554      '3139': "[19] Re-enter transaction",555      '3231': "[21] No action taken",556      '3235': "[25] Unable to locate record in file",557      '3238': "[28] File temporarily not available for update or inquiry",558      '3339': "[39] No credit account",559      '3431': "[41] Lost card, pick up (fraud account)",560      '3433': "[43] Stolen card, pick up (fraud account)",561      '3531': "[51] Not sufficient funds",562      '3532': "[52] No checking account",563      '3533': "[53] No savings account",564      '3534': "[54] Expired card or expiration date is missing",565      '3535': "[55] Incorrect PIN or PIN missing",566      '3537': "[57] Transaction not permitted to cardholder",567      '3538': "[58] Transaction not allowed at terminal",568      '3539': "[59] Suspected fraud",569      '3631': "[61] Exceeds approval amount limit",570      '3632': "[62] Restricted card (card invalid in this region or country)",571      '3633': "[63] Security violation (source is not correct issuer)",572      '3634': "[64] Transaction does not fulfill AML requirement",573      '3635': "[65] Exceeds withdrawal frequency limit",574      '3730': "[70] PIN data required",575      '3734': "[74] Different value than that used for PIN encryption errors",576      '3735': "[75] Allowable number of PIN entry tries exceeded",577      '3736': "[76] Unsolicited reversal",578      '3738': "[78] âBlocked, first usedââTransaction from new cardholder, and card not properly unblocked",579      '3739': "[79] Already reversed (by Switch)",580      '3830': "[80] No financial impact",581      '3831': "[81] Cryptographic error found in PIN",582      '3832': "[82] Negative CAM, dCVV, iCVV, or CVV results",583      '3835': "[85] No reason to decline a request for address verification, CVV2 verification, or a credit voucher or merchandise return",584      '3836': "[86] Cannot verify PIN; for example, no PVV",585      '3839': "[89] Ineligible to receive financial position information (GIV)",586      '3931': "[91] Issuer or switch inoperative and STIP not applicable or not available for this transaction; Time-out when no stand-in; POS Check Service: Destination unavailable; Credit Voucher and Merchandise Return Authorizations: V.I.P. sent the transaction to the issuer, but the issuer was unavailable.",587      '3932': "[92] Financial institution or intermediate network facility cannot be found for routing (receiving institution ID is invalid)",588      '3933': "[93] Transaction cannot be completed - violation of law",589      '3141': "[1A] Additional customer authentication required",590      '4231': "[B1] Surcharge amount not permitted on Visa cards or EBT food stamps (U.S. acquirers only)",591      '4232': "[B2] Surcharge amount not supported by debit network issuer.",592      '4E30': "[N0] Force STIP",593      '4E33': "[N3] Cash service not available",594      '4E34': "[N4] Cash request exceeds issuer or approved limit",595      '4E35': "[N5] Ineligible for resubmission",596      '4E37': "[N7] Decline for CVV2 failure",597      '4E38': "[N8] Transaction amount exceeds preauthorized approval amount",598      '5035': "[P5] Denied PIN unblockâPIN change or unblock request declined by issuer",599      '5036': "[P6] Denied PIN changeârequested PIN unsafe",600      '5131': "[Q1] Card Authentication failed",601      '5230': "[R0] Stop Payment Order",602      '5232': "[R2] Transaction does not qualify for Visa PIN",603      '5233': "[R3] Revocation of all authorizations order",604      '5931': "[Y1] Offline approval. Generated by the reader or terminal",605      '5933': "[Y3] Unable to go online: offline-approved. Generated by the reader or terminal",606      '5A31': "[Z1] Offline declined. Generated by the reader or terminal",607      '5A33': "[Z3] Unable to go online; offline-declined. Generated by the reader or terminal",608    },609    iso3166: {610      4:' ã¢ãã¬ãã¹ã¿ã³',611      8:' ã¢ã«ããã¢',612      10:' 忥µ',613      12:' ã¢ã«ã¸ã§ãªã¢',614      16:' ã¢ã¡ãªã«é ãµã¢ã¢',615      20:' ã¢ã³ãã©',616      24:' ã¢ã³ã´ã©',617      28:' ã¢ã³ãã£ã°ã¢ã»ãã¼ãã¼ã',618      31:' ã¢ã¼ã«ãã¤ã¸ã£ã³',619      32:' ã¢ã«ã¼ã³ãã³',620      36:' ãªã¼ã¹ãã©ãªã¢',621      40:' ãªã¼ã¹ããªã¢',622      44:' ããã',623      48:' ãã¼ã¬ã¼ã³',624      50:' ãã³ã°ã©ãã·ã¥',625      51:' ã¢ã«ã¡ãã¢',626      52:' ãã«ããã¹',627      56:' ãã«ã®ã¼',628      60:' ããã¥ã¼ã',629      64:' ãã¼ã¿ã³',630      68:' ããªãã¢å¤æ°æå½',631      70:' ãã¹ãã¢ã»ãã«ãã§ã´ãã',632      72:' ããã¯ã',633      74:' ãã¼ãå³¶',634      76:' ãã©ã¸ã«',635      84:' ããªã¼ãº',636      86:' ã¤ã®ãªã¹é ã¤ã³ãæ´å°å',637      90:' ã½ãã¢ã³è«¸å³¶',638      92:' ã¤ã®ãªã¹é ã´ã¡ã¼ã¸ã³è«¸å³¶',639      96:' ãã«ãã¤ã»ãã«ãµã©ã¼ã ',640      100:' ãã«ã¬ãªã¢',641      104:' ãã£ã³ãã¼',642      108:' ãã«ã³ã¸',643      112:' ãã©ã«ã¼ã·',644      116:' ã«ã³ãã¸ã¢',645      120:' ã«ã¡ã«ã¼ã³',646      124:' ã«ãã',647      132:' ã«ã¼ããã«ã',648      136:' ã±ã¤ãã³è«¸å³¶',649      140:' ä¸å¤®ã¢ããªã«å
±åå½',650      144:' ã¹ãªã©ã³ã«',651      148:' ãã£ã',652      152:' ããª',653      156:' ä¸è¯äººæ°å
±åå½',654      158:' å°æ¹¾ï¼ä¸è¯æ°å½ï¼',655      162:' ã¯ãªã¹ãã¹å³¶',656      166:' ã³ã³ã¹ï¼ãã¼ãªã³ã°ï¼è«¸å³¶',657      170:' ã³ãã³ãã¢',658      174:' ã³ã¢ã',659      175:' ãã¨ãã',660      178:' ã³ã³ã´å
±åå½',661      180:' ã³ã³ã´æ°ä¸»å
±åå½',662      184:' ã¯ãã¯è«¸å³¶',663      188:' ã³ã¹ã¿ãªã«',664      191:' ã¯ãã¢ãã¢',665      192:' ãã¥ã¼ã',666      196:' ãããã¹',667      203:' ãã§ã³',668      204:' ããã³',669      208:' ãã³ãã¼ã¯',670      212:' ãããã«å½',671      214:' ãããã«å
±åå½',672      218:' ã¨ã¯ã¢ãã«',673      222:' ã¨ã«ãµã«ããã«',674      226:' 赤éã®ãã¢',675      231:' ã¨ããªãã¢',676      232:' ã¨ãªããªã¢',677      233:' ã¨ã¹ããã¢',678      234:' ãã§ãã¼è«¸å³¶',679      238:' ãã©ã¼ã¯ã©ã³ãï¼ãã«ããã¹ï¼è«¸å³¶',680      239:' ãµã¦ã¹ã¸ã§ã¼ã¸ã¢ã»ãµã¦ã¹ãµã³ãã¦ã£ãã諸島',681      242:' ãã£ã¸ã¼',682      246:' ãã£ã³ã©ã³ã',683      248:' ãªã¼ã©ã³ã諸島',684      250:' ãã©ã³ã¹',685      254:' ãã©ã³ã¹é ã®ã¢ã',686      258:' ãã©ã³ã¹é ããªãã·ã¢',687      260:' ãã©ã³ã¹é åæ¹ã»å極å°å',688      262:' ã¸ãã',689      266:' ã¬ãã³',690      268:' ã¸ã§ã¼ã¸ã¢',691      270:' ã¬ã³ãã¢',692      275:' ãã¬ã¹ãã',693      276:' ãã¤ã',694      288:' ã¬ã¼ã',695      292:' ã¸ãã©ã«ã¿ã«',696      296:' ããªãã¹',697      300:' ã®ãªã·ã£',698      304:' ã°ãªã¼ã³ã©ã³ã',699      308:' ã°ã¬ãã',700      312:' ã°ã¢ãã«ã¼ã',701      316:' ã°ã¢ã ',702      320:' ã°ã¢ããã©',703      324:' ã®ãã¢',704      328:' ã¬ã¤ã¢ã',705      332:' ãã¤ã',706      334:' ãã¼ãå³¶ã¨ãã¯ããã«ã諸島',707      336:' ããã«ã³å¸å½',708      340:' ãã³ã¸ã¥ã©ã¹',709      344:' 馿¸¯',710      348:' ãã³ã¬ãªã¼',711      352:' ã¢ã¤ã¹ã©ã³ã',712      356:' ã¤ã³ã',713      360:' ã¤ã³ããã·ã¢',714      364:' ã¤ã©ã³ã»ã¤ã¹ã©ã å
±åå½',715      368:' ã¤ã©ã¯',716      372:' ã¢ã¤ã«ã©ã³ã',717      376:' ã¤ã¹ã©ã¨ã«',718      380:' ã¤ã¿ãªã¢',719      384:' ã³ã¼ãã¸ãã¯ã¼ã«',720      388:' ã¸ã£ãã¤ã«',721      392:' æ¥æ¬',722      398:' ã«ã¶ãã¹ã¿ã³',723      400:' ã¨ã«ãã³',724      404:' ã±ãã¢',725      408:' æé®®æ°ä¸»ä¸»ç¾©äººæ°å
±åå½',726      410:' 大鿰å½',727      414:' ã¯ã¦ã§ã¼ã',728      417:' ãã«ã®ã¹',729      418:' ã©ãªã¹äººæ°æ°ä¸»å
±åå½',730      422:' ã¬ããã³',731      426:' ã¬ã½ã',732      428:' ã©ããã¢',733      430:' ãªããªã¢',734      434:' ãªãã¢',735      438:' ãªããã³ã·ã¥ã¿ã¤ã³',736      440:' ãªãã¢ãã¢',737      442:' ã«ã¯ã»ã³ãã«ã¯',738      446:' ãã«ãª',739      450:' ããã¬ã¹ã«ã«',740      454:' ãã©ã¦ã¤',741      458:' ãã¬ã¼ã·ã¢',742      462:' ã¢ã«ãã£ã',743      466:' ããª',744      470:' ãã«ã¿',745      474:' ãã«ãã£ãã¼ã¯',746      478:' ã¢ã¼ãªã¿ãã¢',747      480:' ã¢ã¼ãªã·ã£ã¹',748      484:' ã¡ãã·ã³',749      492:' ã¢ãã³',750      496:' ã¢ã³ã´ã«',751      498:' ã¢ã«ããå
±åå½',752      499:' ã¢ã³ããã°ã',753      500:' ã¢ã³ãã»ã©ã',754      504:' ã¢ããã³',755      508:' ã¢ã¶ã³ãã¼ã¯',756      512:' ãªãã¼ã³',757      516:' ãããã¢',758      520:' ãã¦ã«',759      524:' ããã¼ã«',760      528:' ãªã©ã³ã',761      531:' ãã¥ã©ã½ã¼',762      533:' ã¢ã«ã',763      534:' ã·ã³ãã»ãã¼ã«ãã³ï¼ãªã©ã³ãé ï¼',764      535:' ããã¼ã«ãã·ã³ãã»ã¦ã¼ã¹ã¿ãã£ã¦ã¹ããã³ãµã',765      540:' ãã¥ã¼ã«ã¬ããã¢',766      548:' ããã¢ã',767      554:' ãã¥ã¼ã¸ã¼ã©ã³ã',768      558:' ãã«ã©ã°ã¢',769      562:' ãã¸ã§ã¼ã«',770      566:' ãã¤ã¸ã§ãªã¢',771      570:' ãã¦ã¨',772      574:' ãã¼ãã©ã¼ã¯å³¶',773      578:' ãã«ã¦ã§ã¼',774      580:' åããªã¢ã諸島',775      581:' åè¡å½é æå°é¢å³¶',776      583:' ãã¯ããã·ã¢é£é¦',777      584:' ãã¼ã·ã£ã«è«¸å³¶',778      585:' ãã©ãª',779      586:' ããã¹ã¿ã³',780      591:' ããã',781      598:' ããã¢ãã¥ã¼ã®ãã¢',782      600:' ãã©ã°ã¢ã¤',783      604:' ãã«ã¼',784      608:' ãã£ãªãã³',785      612:' ããã±ã¢ã³',786      616:' ãã¼ã©ã³ã',787      620:' ãã«ãã¬ã«',788      624:' ã®ãã¢ããµã¦',789      626:' æ±ãã£ã¢ã¼ã«',790      630:' ãã¨ã«ããªã³',791      634:' ã«ã¿ã¼ã«',792      638:' ã¬ã¦ããªã³',793      642:' ã«ã¼ããã¢',794      643:' ãã·ã¢é£é¦',795      646:' ã«ã¯ã³ã',796      652:' ãµã³ã»ãã«ãã«ãã¼',797      654:' ã»ã³ããã¬ãã»ã¢ã»ã³ã·ã§ã³ããã³ããªã¹ã¿ã³ãã¯ã¼ãã£',798      659:' ã»ã³ãã¯ãªã¹ããã¡ã¼ã»ãã¤ãã¹',799      660:' ã¢ã³ã®ã©',800      662:' ã»ã³ãã«ã·ã¢',801      663:' ãµã³ã»ãã«ã¿ã³ï¼ãã©ã³ã¹é ï¼',802      666:' ãµã³ãã¨ã¼ã«å³¶ã»ãã¯ãã³å³¶',803      670:' ã»ã³ããã³ã»ã³ãããã³ã°ã¬ããã£ã¼ã³è«¸å³¶',804      674:' ãµã³ããªã',805      678:' ãµã³ãã¡ã»ããªã³ã·ã',806      682:' ãµã¦ã¸ã¢ã©ãã¢',807      686:' ã»ãã¬ã«',808      688:' ã»ã«ãã¢',809      690:' ã»ã¼ã·ã§ã«',810      694:' ã·ã¨ã©ã¬ãªã',811      702:' ã·ã³ã¬ãã¼ã«',812      703:' ã¹ãããã¢',813      704:' ãããã ',814      705:' ã¹ãããã¢',815      706:' ã½ããªã¢',816      710:' åã¢ããªã«',817      716:' ã¸ã³ããã¨',818      724:' ã¹ãã¤ã³',819      728:' åã¹ã¼ãã³',820      729:' ã¹ã¼ãã³',821      732:' 西ãµãã©',822      740:' ã¹ãªãã ',823      744:' ã¹ã´ã¡ã¼ã«ãã«è«¸å³¶ããã³ã¤ã³ãã¤ã¨ã³å³¶',824      748:' ã¨ã¹ã¯ãã£ã',825      752:' ã¹ã¦ã§ã¼ãã³',826      756:' ã¹ã¤ã¹',827      760:' ã·ãªã¢ã»ã¢ã©ãå
±åå½',828      762:' ã¿ã¸ãã¹ã¿ã³',829      764:' ã¿ã¤',830      768:' ãã¼ã´',831      772:' ãã±ã©ã¦',832      776:' ãã³ã¬',833      780:' ããªããã¼ãã»ããã´',834      784:' ã¢ã©ãé¦é·å½é£é¦',835      788:' ãã¥ãã¸ã¢',836      792:' ãã«ã³',837      795:' ãã«ã¯ã¡ãã¹ã¿ã³',838      796:' ã¿ã¼ã¯ã¹ã»ã«ã¤ã³ã¹è«¸å³¶',839      798:' ããã«',840      800:' ã¦ã¬ã³ã',841      804:' ã¦ã¯ã©ã¤ã',842      807:' åãã±ããã¢',843      818:' ã¨ã¸ãã',844      826:' ã¤ã®ãªã¹',845      831:' ã¬ã¼ã³ã¸ã¼',846      832:' ã¸ã£ã¼ã¸ã¼',847      833:' ãã³å³¶',848      834:' ã¿ã³ã¶ãã¢',849      840:' ã¢ã¡ãªã«åè¡å½',850      850:' ã¢ã¡ãªã«é ã´ã¡ã¼ã¸ã³è«¸å³¶',851      854:' ãã«ãããã¡ã½',852      858:' ã¦ã«ã°ã¢ã¤',853      860:' ã¦ãºããã¹ã¿ã³',854      862:' ãããºã¨ã©ã»ããªãã«å
±åå½',855      876:' ã¦ã©ãªã¹ã»ããã',856      882:' ãµã¢ã¢',857      887:' ã¤ã¨ã¡ã³',858      894:' ã¶ã³ãã¢'859    },860    iso4217: {861      8:"ã¬ã¯",862      12:"ã¢ã«ã¸ã§ãªã¢ãã£ãã¼ã«",863      32:"ã¢ã«ã¼ã³ãã³ãã½",864      36:"ãªã¼ã¹ãã©ãªã¢ãã«",865      44:"ããããã«",866      48:"ãã¼ã¬ã¼ã³ãã£ãã¼ã«",867      50:"ã¿ã«",868      51:"ã¢ã«ã¡ãã¢ãã©ã ",869      52:"ãã«ããã¹ãã«",870      60:"ããã¥ã¼ããã«",871      64:"ãã¥ã«ã¿ã ",872      68:"ããªãã¢ã",873      72:"ãã¼ã©",874      84:"ããªã¼ãºãã«",875      90:"ã½ãã¢ã³è«¸å³¶ãã«",876      96:"ãã«ãã¤ãã«",877      104:"ãã£ãã",878      108:"ãã«ã³ã¸ãã©ã³",879      116:"ãªã¨ã«",880      124:"ã«ãããã«",881      132:"ã«ã¼ããã«ãã»ã¨ã¹ã¯ã¼ã",882      136:"ã±ã¤ãã³è«¸å³¶ãã«",883      144:"ã¹ãªã©ã³ã«ã«ãã¼",884      152:"ããªãã½",885      156:"人æ°å
",886      170:"ã³ãã³ãã¢ãã½",887      174:"ã³ã¢ããã©ã³",888      188:"ã³ã¹ã¿ãªã«ã³ãã³",889      191:"ã¯ã",890      192:"ãã¥ã¼ããã½",891      203:"ãã§ã³ã³ã«ã",892      208:"ãã³ãã¼ã¯ã¯ãã¼ã",893      214:"ãããã«ãã½",894      222:"ã¨ã«ãµã«ããã«ã³ãã³",895      230:"ã¨ããªãã¢ãã«",896      232:"ãã¯ãã¡",897      238:"ãã©ã¼ã¯ã©ã³ã諸島ãã³ã",898      242:"ãã£ã¸ã¼ãã«",899      262:"ã¸ãããã©ã³",900      270:"ãã©ã·",901      292:"ã¸ãã©ã«ã¿ã«ãã³ã",902      320:"ã±ãã¡ã«",903      324:"ã®ãã¢ãã©ã³",904      328:"ã¬ã¤ã¢ããã«",905      332:"ã°ã¼ã«ã",906      340:"ã¬ã³ãã©",907      344:"馿¸¯ãã«",908      348:"ãã©ãªã³ã",909      352:"ã¢ã¤ã¹ã©ã³ãã¯ãã¼ã",910      356:"ã¤ã³ãã«ãã¼",911      360:"ã«ãã¢",912      364:"ã¤ã©ã³ãªã¢ã«",913      368:"ã¤ã©ã¯ãã£ãã¼ã«",914      376:"æ°ã¤ã¹ã©ã¨ã«ã·ã§ã±ã«",915      388:"ã¸ã£ãã¤ã«ãã«",916      392:"å",917      398:"ãã³ã²",918      400:"ã¨ã«ãã³ãã£ãã¼ã«",919      404:"ã±ãã¢ã·ãªã³ã°",920      408:"åæé®®ã¦ã©ã³",921      410:"ã¦ã©ã³",922      414:"ã¯ã¦ã§ã¼ããã£ãã¼ã«",923      417:"ã½ã ",924      418:"ããã",925      422:"ã¬ããã³ãã³ã",926      426:"ããã£",927      430:"ãªããªã¢ãã«",928      434:"ãªãã¢ãã£ãã¼ã«",929      446:"ãã¿ã«",930      454:"ã¯ã¯ãã£",931      458:"ãã¬ã¼ã·ã¢ãªã³ã®ãã",932      462:"ã«ãã£ã¢",933      480:"ã¢ã¼ãªã·ã£ã¹ã«ãã¼",934      484:"ã¡ãã·ã³ãã½",935      496:"ãã¥ã°ã«ã°",936      498:"ã¢ã«ããã¬ã¤",937      504:"ã¢ããã³ãã£ã«ãã ",938      512:"Rial Omani",939      516:"ãããã¢ãã«",940      524:"ããã¼ã«ã«ãã¼",941      532:"ãªã©ã³ãé ã¢ã³ãã£ã«ã®ã«ãã¼",942      533:"ã¢ã«ãã³ãããªã³",943      548:"ãã",944      554:"ãã¥ã¼ã¸ã¼ã©ã³ããã«",945      558:"ã³ã«ãããªã",946      566:"ãã¤ã©",947      578:"ãã«ã¦ã§ã¼ã¯ãã¼ã",948      586:"ããã¹ã¿ã³ã«ãã¼",949      590:"ãã«ãã¢",950      598:"ãã",951      600:"ã°ã¢ã©ã",952      604:"ãã¨ãã½ã«",953      608:"ãã£ãªãã³ãã½",954      634:"ã«ã¿ã¼ã«ãªã¢ã«",955      643:"ãã·ã¢ã«ã¼ãã«",956      646:"ã«ã¯ã³ããã©ã³",957      654:"ã»ã³ããã¬ããã³ã",958      682:"ãµã¦ã¸ãªã¤ã«",959      690:"ã»ã¤ã·ã§ã«ã«ãã¼",960      694:"ã¬ãªã¼ã",961      702:"ã·ã³ã¬ãã¼ã«ãã«",962      704:"ãã³",963      706:"ã½ããªã¢ã·ãªã³ã°",964      710:"ã©ã³ã",965      728:"åã¹ã¼ãã³ãã³ã",966      748:"ãªã©ã³ã¸ã§ã",967      752:"ã¹ã¦ã§ã¼ãã³ã¯ãã¼ã",968      756:"ã¹ã¤ã¹ãã©ã³",969      760:"ã·ãªã¢ãã³ã",970      764:"ãã¼ã",971      776:"ãã¢ã³ã¬",972      780:"ããªããã¼ãããã´ãã«",973      784:"ã¢ã©ãé¦é·å½é£é¦ãã£ã«ãã ",974      788:"ãã¥ãã¸ã¢ãã£ãã¼ã«",975      800:"ã¦ã¬ã³ãã·ãªã³ã°",976      807:"ãã±ããã¢ã»ããã¼ã«",977      818:"ã¨ã¸ãããã³ã",978      826:"è±ãã³ã",979      834:"ã¿ã³ã¶ãã¢ã·ãªã³ã°",980      840:"ç±³ãã«",981      858:"ãã½ã¦ã«ã°ã¢ã¤",982      860:"ã¦ãºããã¹ã¿ã³ã¹ã ",983      882:"ã¿ã©",984      886:"ã¤ã¨ã¡ã³ãªã¢ã«",985      901:"æ°å°æ¹¾ãã«",986      929:"ã¦ã°ã¤ã¤",987      930:"ããã©",988      931:"ãã½ã³ã³ãã¼ããã«",989      932:"ã¸ã³ããã¨ãã«",990      934:"ãã«ã¯ã¡ãã¹ã¿ã³æ°ãããã",991      936:"ã¬ã¼ãã»ãã£",992      937:"ããªãã«",993      938:"ã¹ã¼ãã³ãã³ã",994      940:"ã¦ã«ã°ã¢ã¤ãã½ã¢ã³ã¦ããã¼ãºã¤ã³ããã¯ã¹ï¼URUIURUIï¼",995      941:"ã»ã«ãã¢ãã£ãã¼ã«",996      943:"ã¢ã¶ã³ãã¼ã¯ã¡ã¿ãªãã¯",997      944:"ã¢ã¼ã«ãã¤ã¸ã£ã³ãããã",998      946:"ã«ã¼ããã¢ã¬ã¤",999      947:"WIRã¦ã¼ã",1000      948:"WIRãã©ã³",1001      949:"ãã«ã³ãªã©",1002      950:"CFAãã©ã³BEAC",1003      951:"æ±ã«ãªãã»ãã«",1004      951:"æ±ã«ãªããã«",1005      952:"CFAãã©ã³BCEAO",1006      953:"CFPãã©ã³",1007      960:"SDRï¼ç¹å¥å¼åºæ¨©ï¼",1008      965:"ADBã®ä¼è¨åä½",1009      967:"ã¶ã³ãã¢ã¯ã¯ãã£",1010      968:"ã¹ãªãã ãã«",1011      969:"ããã¬ã¹ã«ã«ã®ã¢ãªã¢ãªã¼",1012      970:"Unidad de Valor Real",1013      971:"ã¢ãã¬ã",1014      972:"ã½ã¢ã",1015      973:"ã¯ã¯ã³ã¶",1016      974:"ãã©ã«ã¼ã·ã«ã¼ãã«",1017      975:"ãã«ã¬ãªã¢ã¬ã",1018      976:"ã³ã³ã´ãã©ã³",1019      977:"ã³ã³ãã¼ããã«ãã¼ã¯",1020      978:"ã¦ã¼ã",1021      979:"ã¡ãã·ã³ã®Unidad de Inversionï¼UDIï¼",1022      980:"ããªã´ãã£",1023      981:"ã©ãª",1024      984:"ã ãã«",1025      985:"ãºãã",1026      986:"ãã©ã¸ã«ã¬ã¢ã«",1027      990:"ã㪠ã¦ããã»ãã»ãã©ã¡ã³ã",1028      994:"ã¹ã¯ã¬",1029      997:"ç±³ãã«ï¼ç¿æ¥ï¼"1030    },1031    terminalType: {1032      11: "Financial Institution - [Attended] Online only",1033      12: "Financial Institution - [Attended] Offline with online capability",1034      13: "Financial Institution - [Attended] Offline only",1035      14: "Financial Institution - [Unttended] Online only",1036      15: "Financial Institution - [Unttended] Offline with online capability",1037      16: "Financial Institution - [Unttended] Offline only",1038      21: "Merchant - [Attended] Online only",1039      22: "Merchant - [Attended] Offline with online capability",1040      23: "Merchant - [Attended] Offline only",1041      24: "Merchant - [Unttended] Online only",1042      25: "Merchant - [Unttended] Offline with online capability",1043      26: "Merchant - [Unttended] Offline only",1044      34: "Cardholder - [Unttended] Online only",1045      35: "Cardholder - [Unttended] Offline with online capability",1046      36: "Cardholder - [Unttended] Offline only",1047    },1048    serviceCode: {1049      101: "Magnetic-stipe card; international use",1050      120: "Magnetic-stripe card; international use; PIN is required",1051      121: "Magnetic-stripe card; international use; online authorization required for all transactions",1052      201: "EMV chip card; international use",1053      221: "EMV chip card; international use; online authorization required for all transactions",1054      601: "National-use EMV chip credit and debit cards",1055      000: "Not Valid",1056      999: "Not Valid",1057    },1058    posEntryMode: {1059      01: "Manual Key Entry",1060      05: "Chip read",1061      95: "Chip read",1062      07: "Contactless, using chip data rules",1063      02: "Magnetic-stripe read",1064      90: "Magnetic-stripe read",1065      91: "Contactless, using magnetic-stripe data rules",1066    },1067    tvr: [1068      [1069        {bin: "1xxxxxxx", meaning: "Offline data authentication was not performed"},1070        {bin: "x1xxxxxx", meaning: "SDA failed"},1071        {bin: "xx1xxxxx", meaning: "ICC data missing"},1072        {bin: "xxx1xxxx", meaning: "Card appears on terminal exception file (There is no requirement in this specification for an exception file, but it is recognised that some terminals may have this capability.)"},1073        {bin: "xxxx1xxx", meaning: "DDA failed"},1074        {bin: "xxxxx1xx", meaning: "CDA failed"},1075        {bin: "xxxxxx0x", meaning: "RFU"},1076        {bin: "xxxxxxx0", meaning: "RFU"},1077      ], [1078        {bin: "1xxxxxxx", meaning: "ICC and terminal have different application versions"},1079        {bin: "x1xxxxxx", meaning: "Expired application"},1080        {bin: "xx1xxxxx", meaning: "Application not yet effective"},1081        {bin: "xxx1xxxx", meaning: "Requested service not allowed for card product"},1082        {bin: "xxxx1xxx", meaning: "New card"},1083        {bin: "xxxxx0xx", meaning: "RFU"},1084        {bin: "xxxxxx0x", meaning: "RFU"},1085        {bin: "xxxxxxx0", meaning: "RFU"},1086      ], [1087        {bin: "1xxxxxxx", meaning: "Cardholder verification was not successful"},1088        {bin: "x1xxxxxx", meaning: "Unrecognised CVM"},1089        {bin: "xx1xxxxx", meaning: "PIN Try Limit exceeded"},1090        {bin: "xxx1xxxx", meaning: "PIN entry required and PIN pad not present or not working"},1091        {bin: "xxxx1xxx", meaning: "PIN entry required, PIN pad present, but PIN was not entered"},1092        {bin: "xxxxx1xx", meaning: "Online PIN entered"},1093        {bin: "xxxxxx0x", meaning: "RFU"},1094        {bin: "xxxxxxx0", meaning: "RFU"},1095      ], [1096        {bin: "1xxxxxxx", meaning: "Transaction exceeds floor limit"},1097        {bin: "x1xxxxxx", meaning: "Lower consecutive offline limit exceeded"},1098        {bin: "xx1xxxxx", meaning: "Upper consecutive offline limit exceeded"},1099        {bin: "xxx1xxxx", meaning: "Transaction selected randomly for online processing"},1100        {bin: "xxxx1xxx", meaning: "Merchant forced transaction online"},1101        {bin: "xxxxx0xx", meaning: "RFU"},1102        {bin: "xxxxxx0x", meaning: "RFU"},1103        {bin: "xxxxxxx0", meaning: "RFU"},1104      ], [1105        {bin: "1xxxxxxx", meaning: "Default TDOL used"},1106        {bin: "x1xxxxxx", meaning: "Issuer authentication failed"},1107        {bin: "xx1xxxxx", meaning: "Script processing failed before final GENERATE AC"},1108        {bin: "xxx1xxxx", meaning: "Script processing failed after final GENERATE AC"},1109        {bin: "xxxx0xxx", meaning: "RFU"},1110        {bin: "xxxxx0xx", meaning: "RFU"},1111        {bin: "xxxxxx0x", meaning: "RFU"},1112        {bin: "xxxxxxx0", meaning: "RFU"},1113      ]1114    ],1115    tsi: [1116      [1117        {bin: "1xxxxxxx", meaning: "Offline data authentication was performed"},1118        {bin: "x1xxxxxx", meaning: "Cardholder verification was performed"},1119        {bin: "xx1xxxxx", meaning: "Card risk management was performed"},1120        {bin: "xxx1xxxx", meaning: "Issuer authentication was performed"},1121        {bin: "xxxx1xxx", meaning: "Terminal risk management was performed"},1122        {bin: "xxxxx1xx", meaning: "Script processing was performed"},1123        {bin: "xxxxxx0x", meaning: "RFU"},1124        {bin: "xxxxxxx0", meaning: "RFU"},1125      ],1126      [1127        {bin: "0xxxxxxx", meaning: "RFU"},1128        {bin: "x0xxxxxx", meaning: "RFU"},1129        {bin: "xx0xxxxx", meaning: "RFU"},1130        {bin: "xxx0xxxx", meaning: "RFU"},1131        {bin: "xxxx0xxx", meaning: "RFU"},1132        {bin: "xxxxx0xx", meaning: "RFU"},1133        {bin: "xxxxxx0x", meaning: "RFU"},1134        {bin: "xxxxxxx0", meaning: "RFU"},1135      ],1136    ],1137    auc: [1138      [1139        {bin: "1xxxxxxx", meaning: "Valid for domestic cash transactions"},1140        {bin: "x1xxxxxx", meaning: "Valid for international cash transactions"},1141        {bin: "xx1xxxxx", meaning: "Valid for domestic goods"},1142        {bin: "xxx1xxxx", meaning: "Valid for international goods"},1143        {bin: "xxxx1xxx", meaning: "Valid for domestic services"},1144        {bin: "xxxxx1xx", meaning: "Valid for international services"},1145        {bin: "xxxxxx1x", meaning: "Valid at ATMs"},1146        {bin: "xxxxxxx1", meaning: "Valid at terminals other than ATMs"},1147      ],1148      [1149        {bin: "1xxxxxxx", meaning: "Domestic cashback allowed"},1150        {bin: "x1xxxxxx", meaning: "International cashback allowed"},1151        {bin: "xx0xxxxx", meaning: "RFU"},1152        {bin: "xxx0xxxx", meaning: "RFU"},1153        {bin: "xxxx0xxx", meaning: "RFU"},1154        {bin: "xxxxx0xx", meaning: "RFU"},1155        {bin: "xxxxxx0x", meaning: "RFU"},1156        {bin: "xxxxxxx0", meaning: "RFU"},1157      ],1158    ],1159    aip: [1160      [1161        {bin: "0xxxxxxx", meaning: "RFU"},1162        {bin: "x1xxxxxx", meaning: "SDA supported"},1163        {bin: "xx1xxxxx", meaning: "DDA supported"},1164        {bin: "xxx1xxxx", meaning: "Cardholder verification is supported"},1165        {bin: "xxxx1xxx", meaning: "Terminal risk management is to be performed"},1166        {bin: "xxxxx1xx", meaning: "Issuer authentication is supported (When this bit is set to 1, Issuer Authentication using the EXTERNAL AUTHENTICATE command is supported)"},1167        {bin: "xxxxxx0x", meaning: "RFU"},1168        {bin: "xxxxxxx1", meaning: "CDA supported"},1169      ],1170      [1171        {bin: "1xxxxxxx", meaning: "Reserved for use by the EMV Contactless Specifications"},1172        {bin: "x1xxxxxx", meaning: "RFU"},1173        {bin: "xx0xxxxx", meaning: "RFU"},1174        {bin: "xxx0xxxx", meaning: "RFU"},1175        {bin: "xxxx0xxx", meaning: "RFU"},1176        {bin: "xxxxx0xx", meaning: "RFU"},1177        {bin: "xxxxxx0x", meaning: "RFU"},1178        {bin: "xxxxxxx0", meaning: "RFU"},1179      ]1180    ],1181    cvm: [1182      [1183        {bin: "0xxxxxxx", meaning: "RFU"},1184        {bin: "x0xxxxxx", meaning: "Fail cardholder verification if this CVM is unsuccessful"},1185        {bin: "x1xxxxxx", meaning: "Apply succeeding CV Rule if this CVM is unsuccessful"},1186        {bin: "xx000000", meaning: "Fail CVM processing"},1187        {bin: "xx000001", meaning: "Plaintext PIN verification performed by ICC"},1188        {bin: "xx000010", meaning: "Enciphered PIN verified online"},1189        {bin: "xx000011", meaning: "Plaintext PIN verification performed by ICC and signature (paper)"},1190        {bin: "xx000100", meaning: "Enciphered PIN verification performed by ICC"},1191        {bin: "xx000101", meaning: "Enciphered PIN verification performed by ICC and signature (paper)"},1192        {bin: "xx0xxxxx", meaning: "Values in the range 000110-011101 reserved for future use by this specification"},1193        {bin: "xx011110", meaning: "Signature (paper)"},1194        {bin: "xx011111", meaning: "No CVM required "},1195        {bin: "xx10xxxx", meaning: "Values in the range 100000-101111 reserved for use by the individual payment systems"},1196        {bin: "xx11xxxx", meaning: "Values in the range 110000-111110 reserved for use by the issuer"},1197        {bin: "xx111111", meaning: "This value is not available for use"},1198      ],1199      [1200        {bin: "00000000", meaning: "Always"},1201        {bin: "00000001", meaning: "If unattended cash"},1202        {bin: "00000010", meaning: "If not unattended cash and not manual cash and not purchase with cashback"},1203        {bin: "00000011", meaning: "If terminal supports the CVM (For Condition Codes '01', '04', and '05', please refer to EMVCo General Bulletin No. 14 - Migration Schedule for New CVM Condition Codes.)"},1204        {bin: "00000100", meaning: "If manual cash"},1205        {bin: "00000101", meaning: "If purchase with cashback"},1206        {bin: "00000110", meaning: "If transaction is in the application currency 21 and is under X value (see section 10.5 for a discussion of âXâ)"},1207        {bin: "00000111", meaning: "If transaction is in the application currency and is over X value"},1208        {bin: "00001000", meaning: "If transaction is in the application currency and is under Y value (see section 10.5 for a discussion of âYâ)"},1209        {bin: "00001001", meaning: "If transaction is in the application currency and is over Y value"},1210        {bin: "0xxx1x1x", meaning: "RFU"},1211        {bin: "1xxxxxxx", meaning: "Reserved for use by individual payment systems"},1212      ],1213      [1214        {bin: "00000000", meaning: "Unknown (for example, for signature)"},1215        {bin: "00000001", meaning: "Failed (for example, for offline PIN) or no CVM Condition Code was satisfied / the CVM Code was not recognised / not supported"},1216        {bin: "00000010", meaning: "Successful (for example, for offline PIN)"},1217      ]1218    ],1219    cid: [1220      [1221        {bin: "00xxxxxx", meaning: "AAC"},1222        {bin: "01xxxxxx", meaning: "TC"},1223        {bin: "10xxxxxx", meaning: "ARQC"},1224        {bin: "11xxxxxx", meaning: "RFU"},1225        {bin: "xxxxxxxx", meaning: "Payment System-specific cryptogram"},1226        {bin: "xxxx0xxx", meaning: "No advice required"},1227        {bin: "xxxx1xxx", meaning: "Advice required"},1228        {bin: "xxxxxxxx", meaning: "Reason/advice code"},1229        {bin: "xxxxx000", meaning: "[Reason/advice code] No information given"},1230        {bin: "xxxxx001", meaning: "[Reason/advice code] Service not allowed"},1231        {bin: "xxxxx010", meaning: "[Reason/advice code] PIN Try Limit exceeded"},1232        {bin: "xxxxx011", meaning: "[Reason/advice code] Issuer authentication failed"},1233        {bin: "xxxxx1xx", meaning: "[Reason/advice code] Other values RFU"},1234      ],1235    ],1236    iad: [1237      [1238        {bin: "xxxxxxxx", meaning: "Length Indicator. Length of EMVCo-defined data in IAD. Set to '0F'"},1239      ],1240      [1241        {bin: "xxxxxxxx", meaning: "Derivation Key Index (DKI)"},1242      ],1243      [1244        {bin: "xxxxxxxx", meaning: "Common Core Identifier (CCI)"},1245      ],1246      [1247        {bin: "xxxxxxxx", meaning: "Length of Card Verification Results(CVR)"},1248      ],1249      [1250        {bin: "xxxxxxxx", meaning: "CVR: Application Cryptogram Type Returned in Second GENERATE AC"},1251        {bin: "00xxxxxx", meaning: "CVR: [Second GENERATE AC] AAC"},1252        {bin: "01xxxxxx", meaning: "CVR: [Second GENERATE AC] TC"},1253        {bin: "10xxxxxx", meaning: "CVR: [Second GENERATE AC] Second GENERATE AC Not Requested"},1254        {bin: "11xxxxxx", meaning: "CVR: [Second GENERATE AC] RFU"},1255        {bin: "xxxxxxxx", meaning: "CVR: Application Cryptogram Type Returned in First GENERATE AC"},1256        {bin: "xx00xxxx", meaning: "CVR: [First GENERATE AC] AAC"},1257        {bin: "xx01xxxx", meaning: "CVR: [First GENERATE AC] TC"},1258        {bin: "xx10xxxx", meaning: "CVR: [First GENERATE AC] ARQC"},1259        {bin: "xx11xxxx", meaning: "CVR: [First GENERATE AC] RFU"},1260        {bin: "xxxx1xxx", meaning: "CVR: CDA Performed"},1261        {bin: "xxxxx1xx", meaning: "CVR: Offline DDA Performed"},1262        {bin: "xxxxxx1x", meaning: "CVR: Issuer Authentication Not Performed"},1263        {bin: "xxxxxxx1", meaning: "CVR: Issuer Authentication Failed"},1264      ],1265      [1266        {bin: "xxxxxxxx", meaning: "Low Order Nibble of PIN Try Counter"},1267        {bin: "xxxx1xxx", meaning: "Offline PIN Verification Performed"},1268        {bin: "xxxxx1xx", meaning: "Offline PIN Verification Performed and PIN Not Successfully Verified"},1269        {bin: "xxxxxx1x", meaning: "PIN Try Limit Exceeded"},1270        {bin: "xxxxxxx1", meaning: "Last Online Transaction Not Completed"},1271      ],1272      [1273        {bin: "1xxxxxxx", meaning: "Lower Offline Transaction Count Limit Exceeded"},1274        {bin: "x1xxxxxx", meaning: "Upper Offline Transaction Count Limit Exceeded"},1275        {bin: "xx1xxxxx", meaning: "Lower Cumulative Offline Amount Limit Exceeded"},1276        {bin: "xxx1xxxx", meaning: "Upper Cumulative Offline Amount Limit Exceeded"},1277        {bin: "xxxx1xxx", meaning: "Issuer-discretionary bit 1"},1278        {bin: "xxxxx1xx", meaning: "Issuer-discretionary bit 2"},1279        {bin: "xxxxxx1x", meaning: "Issuer-discretionary bit 3"},1280        {bin: "xxxxxxx1", meaning: "Issuer-discretionary bit 4"},1281      ],1282      [1283        {bin: "xxxxxxxx", meaning: "Number of Successfully Processed Issuer Script Commands Containing Secure Messaging"},1284        {bin: "xxxx1xxx", meaning: "Issuer Script Processing Failed"},1285        {bin: "xxxxx1xx", meaning: "Offline Data Authentication Failed on Previous Transaction"},1286        {bin: "xxxxxx1x", meaning: "Go Online on Next Transaction Was Set"},1287        {bin: "xxxxxxx1", meaning: "Unable to go Online"},1288      ],1289      [1290        {bin: "00000000", meaning: "RFU"},1291      ],1292    ],1293    terminalCapability: [1294      [1295        {bin: "1xxxxxxx", meaning: "Manual key entry"},1296        {bin: "x1xxxxxx", meaning: "Magnetic stripe"},1297        {bin: "xx1xxxxx", meaning: "IC with contacts"},1298        {bin: "xxx0xxxx", meaning: "RFU"},1299        {bin: "xxxx0xxx", meaning: "RFU"},1300        {bin: "xxxxx0xx", meaning: "RFU"},1301        {bin: "xxxxxx0x", meaning: "RFU"},1302        {bin: "xxxxxxx0", meaning: "RFU"},1303      ],1304      [1305        {bin: "1xxxxxxx", meaning: "Plaintext PIN for ICC verification"},1306        {bin: "x1xxxxxx", meaning: "Enciphered PIN for online verification"},1307        {bin: "xx1xxxxx", meaning: "Signature (paper)"},1308        {bin: "xxx1xxxx", meaning: "Enciphered PIN for offline verification"},1309        {bin: "xxxx1xxx", meaning: "No CVM Required"},1310        {bin: "xxxxx0xx", meaning: "RFU"},1311        {bin: "xxxxxx0x", meaning: "RFU"},1312        {bin: "xxxxxxx0", meaning: "RFU"},1313      ],1314      [1315        {bin: "1xxxxxxx", meaning: "SDA (Static Data Authentication)"},1316        {bin: "x1xxxxxx", meaning: "DDA (Dynamic Data Authentication)"},1317        {bin: "xx1xxxxx", meaning: "Card capture"},1318        {bin: "xxx0xxxx", meaning: "RFU"},1319        {bin: "xxxx1xxx", meaning: "CDA (Combined DDA/Application Cryptogram Generation)"},1320        {bin: "xxxxx0xx", meaning: "RFU"},1321        {bin: "xxxxxx0x", meaning: "RFU"},1322        {bin: "xxxxxxx0", meaning: "RFU"},1323      ]1324    ],1325    ttq: [1326      [1327        {bin: "1xxxxxxx", meaning: "Mag-stripe mode supported"},1328        {bin: "0xxxxxxx", meaning: "Mag-stripe mode not supported"},1329        {bin: "xx1xxxxx", meaning: "EMV mode supported"},1330        {bin: "xx0xxxxx", meaning: "EMV mode not supported"},1331        {bin: "xxx1xxxx", meaning: "EMV contact chip supported"},1332        {bin: "xxx0xxxx", meaning: "EMV contact chip not supported"},1333        {bin: "xxxx1xxx", meaning: "Offline-only reader"},1334        {bin: "xxxx0xxx", meaning: "Online capable reader"},1335        {bin: "xxxxx1xx", meaning: "Online PIN supported"},1336        {bin: "xxxxx0xx", meaning: "Online PIN not supported"},1337        {bin: "xxxxxx1x", meaning: "Signature supported"},1338        {bin: "xxxxxx0x", meaning: "Signature not supported"},1339        {bin: "xxxxxxx1", meaning: "Offline Data Authentication for Online Authorizations supported"},1340        {bin: "xxxxxxx0", meaning: "Offline Data Authentication for Online Authorizations not supported"},1341      ],1342      [1343        {bin: "1xxxxxxx", meaning: "Online cryptogram required"},1344        {bin: "0xxxxxxx", meaning: "Online cryptogram not required"},1345        {bin: "x1xxxxxx", meaning: "CVM required"},1346        {bin: "x0xxxxxx", meaning: "CVM not required"},1347        {bin: "xx1xxxxx", meaning: "(Contact Chip) Offline PIN supported"},1348        {bin: "xx0xxxxx", meaning: "(Contact Chip) Offline PIN not supported"},1349      ],1350      [1351        {bin: "1xxxxxxx", meaning: "Issuer Update Processing supported"},1352        {bin: "0xxxxxxx", meaning: "Issuer Update Processing not supported"},1353        {bin: "x1xxxxxx", meaning: "Consumer Device CVM supported"},1354        {bin: "x0xxxxxx", meaning: "Consumer Device CVM not supported"},1355      ],1356      [1357        {bin: "xxxxxxxx", meaning: "RFU"},1358      ],1359    ],1360    1361    ctq: [1362      [1363        {bin: "1xxxxxxx", meaning: "Online PIN Required"},1364        {bin: "x1xxxxxx", meaning: "Signature Required"},1365        {bin: "xx1xxxxx", meaning: "Go Online if Offline Data Authentication Fails and Reader is online capable"},1366        {bin: "xxx1xxxx", meaning: "Switch Interface if Offline Data Authentication fails and Reader supports contact chip."},1367        {bin: "xxxx1xxx", meaning: "Go Online if Application Expired"},1368        {bin: "xxxxx1xx", meaning: "Switch Interface for Cash Transactions"},1369        {bin: "xxxxxx1x", meaning: "Switch Interface for Cashback Transactions"},1370        {bin: "xxxxxxx0", meaning: "RFU"},1371      ],1372      [1373        {bin: "1xxxxxxx", meaning: "Consumer Device CVM Performed"},1374        {bin: "x1xxxxxx", meaning: "Card supports Issuer Update Processing at the POS"},1375        {bin: "xx1xxxxx", meaning: "RFU"},1376        {bin: "xxx1xxxx", meaning: "RFU"},1377        {bin: "xxxx1xxx", meaning: "RFU"},1378        {bin: "xxxxx1xx", meaning: "RFU"},1379        {bin: "xxxxxx1x", meaning: "RFU"},1380        {bin: "xxxxxxx1", meaning: "RFU"},1381      ]1382    ],1383    atc: [1384      [1385        {bin: "1xxxxxxx", meaning: "Cash"},1386        {bin: "x1xxxxxx", meaning: "Goods"},1387        {bin: "xx1xxxxx", meaning: "Services"},1388        {bin: "xxx1xxxx", meaning: "Cashback"},1389        {bin: "xxxx1xxx", meaning: "Inquiry"},1390        {bin: "xxxxx1xx", meaning: "Transfer"},1391        {bin: "xxxxxx1x", meaning: "Payment"},1392        {bin: "xxxxxxx1", meaning: "Administrative"},1393      ],1394      [1395        {bin: "1xxxxxxx", meaning: "Cash Deposit"},1396        {bin: "x1xxxxxx", meaning: "RFU"},1397        {bin: "xx1xxxxx", meaning: "RFU"},1398        {bin: "xxx1xxxx", meaning: "RFU"},1399        {bin: "xxxx1xxx", meaning: "RFU"},1400        {bin: "xxxxx1xx", meaning: "RFU"},1401        {bin: "xxxxxx1x", meaning: "RFU"},1402        {bin: "xxxxxxx1", meaning: "RFU"},1403      ],1404      [1405        {bin: "1xxxxxxx", meaning: "Numeric keys"},1406        {bin: "x1xxxxxx", meaning: "Alphabetical and special characters keys"},1407        {bin: "xx1xxxxx", meaning: "Command keys"},1408        {bin: "xxx1xxxx", meaning: "Function keys"},1409        {bin: "xxxx1xxx", meaning: "RFU"},1410        {bin: "xxxxx1xx", meaning: "RFU"},1411        {bin: "xxxxxx1x", meaning: "RFU"},1412        {bin: "xxxxxxx1", meaning: "RFU"},1413      ],1414      [1415        {bin: "1xxxxxxx", meaning: "Print, attendant"},1416        {bin: "x1xxxxxx", meaning: "Print, cardholder"},1417        {bin: "xx1xxxxx", meaning: "Display, attendant"},1418        {bin: "xxx1xxxx", meaning: "Display, cardholder"},1419        {bin: "xxxx1xxx", meaning: "RFU"},1420        {bin: "xxxxx1xx", meaning: "RFU"},1421        {bin: "xxxxxx1x", meaning: "Code table 10"},1422        {bin: "xxxxxxx1", meaning: "Code table 9"},1423      ],1424      [1425        {bin: "1xxxxxxx", meaning: "Code table 8"},1426        {bin: "x1xxxxxx", meaning: "Code table 7"},1427        {bin: "xx1xxxxx", meaning: "Code table 6"},1428        {bin: "xxx1xxxx", meaning: "Code table 5"},1429        {bin: "xxxx1xxx", meaning: "Code table 4"},1430        {bin: "xxxxx1xx", meaning: "Code table 3"},1431        {bin: "xxxxxx1x", meaning: "Code table 2"},1432        {bin: "xxxxxxx1", meaning: "Code table 1"},1433      ],1434    ],1435    cardDataInputCapability: [1436      [1437        {bin: "1xxxxxxx", meaning: "Manual key entry"},1438        {bin: "x1xxxxxx", meaning: "Magnetic stripe"},1439        {bin: "xx1xxxxx", meaning: "IC with contacts"},1440        {bin: "xxx1xxxx", meaning: "RFU"},1441        {bin: "xxxx1xxx", meaning: "RFU"},1442        {bin: "xxxxx1xx", meaning: "RFU"},1443        {bin: "xxxxxx1x", meaning: "RFU"},1444        {bin: "xxxxxxx1", meaning: "RFU"},1445      ],1446    ],1447    cvmCapability_cvmRequired: [1448      [1449        {bin: "1xxxxxxx", meaning: "Plaintext PIN for ICC verification"},1450        {bin: "x1xxxxxx", meaning: "Enciphered PIN for online verification"},1451        {bin: "xx1xxxxx", meaning: "Signature (paper)"},1452        {bin: "xxx1xxxx", meaning: "Enciphered PIN for offline verification"},1453        {bin: "xxxx1xxx", meaning: "No CVM required"},1454        {bin: "xxxxx1xx", meaning: "RFU"},1455        {bin: "xxxxxx1x", meaning: "RFU"},1456        {bin: "xxxxxxx1", meaning: "RFU"},1457      ],1458    ],1459    cvmCapability_nocvmRequired: [1460      [1461        {bin: "1xxxxxxx", meaning: "Plaintext PIN for ICC verification"},1462        {bin: "x1xxxxxx", meaning: "Enciphered PIN for online verification"},1463        {bin: "xx1xxxxx", meaning: "Signature (paper)"},1464        {bin: "xxx1xxxx", meaning: "Enciphered PIN for offline verification"},1465        {bin: "xxxx1xxx", meaning: "No CVM required"},1466        {bin: "xxxxx1xx", meaning: "RFU"},1467        {bin: "xxxxxx1x", meaning: "RFU"},1468        {bin: "xxxxxxx1", meaning: "RFU"},1469      ],1470    ],1471    cvmList: [1472      [1473        {bin: "0xxxxxxx", meaning: "RFU"},1474        {bin: "x0xxxxxx", meaning: "Fail cardholder verification if this CVM is unsuccessful"},1475        {bin: "x1xxxxxx", meaning: "Apply succeeding CV Rule if this CVM is unsuccessful"},1476        {bin: "xx000000", meaning: "Fail CVM processing"},1477        {bin: "xx000001", meaning: "Plaintext PIN verification performed by ICC"},1478        {bin: "xx000010", meaning: "Enciphered PIN verified online"},1479        {bin: "xx000011", meaning: "Plaintext PIN verification performed by ICC and signature (paper)"},1480        {bin: "xx000100", meaning: "Enciphered PIN verification performed by ICC"},1481        {bin: "xx000101", meaning: "Encpihered PIN verification performed by ICC and signature (paper)"},1482        {bin: "xx000110", meaning: "Values in the range 000110-011101 reserved for future use by this specification"},1483        {bin: "xx000111", meaning: "Values in the range 000110-011101 reserved for future use by this specification"},1484        {bin: "xx001xxx", meaning: "Values in the range 000110-011101 reserved for future use by this specification"},1485        {bin: "xx010xxx", meaning: "Values in the range 000110-011101 reserved for future use by this specification"},1486        {bin: "xx0110xx", meaning: "Values in the range 000110-011101 reserved for future use by this specification"},1487        {bin: "xx011101", meaning: "Values in the range 000110-011101 reserved for future use by this specification"},1488        {bin: "xx011110", meaning: "Signature (paper)"},1489        {bin: "xx011111", meaning: "No CVM required"},1490        {bin: "xx10xxxx", meaning: "Values in the range 100000-101111 reserved for use by the individual payment systems"},1491        {bin: "xx11xxxx", meaning: "Values in the range 110000-111110 reserved for use by the issuer"},1492        {bin: "xx111111", meaning: "This value is not available for use"}1493      ],1494      [1495        {bin: "00000000", meaning: "Always"},1496        {bin: "00000001", meaning: "If unattended cash"},1497        {bin: "00000010", meaning: "If not unattended cash and not manual cash and not purchase with cashback"},1498        {bin: "00000011", meaning: "If terminal supports the CVM"},1499        {bin: "00000100", meaning: "If manual cash"},1500        {bin: "00000101", meaning: "If purchase with cashback"},1501        {bin: "00000110", meaning: "If transaction is in the application currency and is under X value"},1502        {bin: "00000111", meaning: "If transaction is in the application currency and is over X value"},1503        {bin: "00001000", meaning: "If transaciton is in the application currency and is under Y value"},1504        {bin: "00001001", meaning: "If transaciton is in the application currency and is over Y value"},1505        {bin: "00001010", meaning: "RFU"},1506        {bin: "00001011", meaning: "RFU"},1507        {bin: "0xxx11xx", meaning: "RFU"},1508        {bin: "0xx1xxxx", meaning: "RFU"},1509        {bin: "0x1xxxxx", meaning: "RFU"},1510        {bin: "01xxxxxx", meaning: "RFU"},1511        {bin: "1xxxxxxx", meaning: "Reserved for use by individual payment systems"},1512      ],1513    ],1514    dc_ac_type: [1515      [1516        {bin: "00xxxxxx", meaning: "AAC"},1517        {bin: "01xxxxxx", meaning: "TC"},1518        {bin: "10xxxxxx", meaning: "ARQC"},1519        {bin: "11xxxxxx", meaning: "RFU"},1520        {bin: "xx1xxxxx", meaning: "RFU"},1521        {bin: "xxx1xxxx", meaning: "RFU"},1522        {bin: "xxxx1xxx", meaning: "RFU"},1523        {bin: "xxxxx1xx", meaning: "RFU"},1524        {bin: "xxxxxx1x", meaning: "RFU"},1525        {bin: "xxxxxxx1", meaning: "RFU"},1526      ],1527    ],1528    ds_ods_info: [1529      [1530        {bin: "1xxxxxxx", meaning: "Permanent slot type"},1531        {bin: "x1xxxxxx", meaning: "Volatile slot type"},1532        {bin: "xx1xxxxx", meaning: "Low volatility"},1533        {bin: "xxx1xxxx", meaning: "RFU"},1534        {bin: "xxxx1xxx", meaning: "Decline payment transaction in case of data storage error"},1535        {bin: "xxxxx1xx", meaning: "RFU"},1536        {bin: "xxxxxx1x", meaning: "RFU"},1537        {bin: "xxxxxxx1", meaning: "RFU"},1538      ],1539    ],1540    ds_ods_info_for_reader: [1541      [1542        {bin: "1xxxxxxx", meaning: "Usable for TC"},1543        {bin: "x1xxxxxx", meaning: "Usable for ARQC"},1544        {bin: "xx1xxxxx", meaning: "Usable for AAC"},1545        {bin: "xxx1xxxx", meaning: "RFU"},1546        {bin: "xxxx1xxx", meaning: "RFU"},1547        {bin: "xxxxx1xx", meaning: "Stop if no DS ODS Term"},1548        {bin: "xxxxxx1x", meaning: "Stop if write failed"},1549        {bin: "xxxxxxx1", meaning: "RFU"},1550      ],1551    ],1552    kernelConfiguration: [1553      [1554        {bin: "1xxxxxxx", meaning: "Mag-stripe mode contactless transactions not supported (Not applicable if MAG not implemented)"},1555        {bin: "x1xxxxxx", meaning: "EMV mode contactless transactions not supported (Not applicable if MAG not implemented)"},1556        {bin: "xx1xxxxx", meaning: "On device cardholder verification supported"},1557        {bin: "xxx1xxxx", meaning: "Relay resistance protocol supported"},1558        {bin: "xxxx1xxx", meaning: "Reserved for Payment system"},1559        {bin: "xxxxx1xx", meaning: "Read all records even when no CDA"},1560        {bin: "xxxxxx1x", meaning: "RFU"},1561        {bin: "xxxxxxx1", meaning: "RFU"},1562      ],1563    ],1564    outcomeParameterSet: [1565      [1566        {bin: "0001xxxx", meaning: "Status = APPROVED"},1567        {bin: "0010xxxx", meaning: "Status = DECLINED"},1568        {bin: "0011xxxx", meaning: "Status = ONLINE REQUEST"},1569        {bin: "0100xxxx", meaning: "Status = END APPLICATION"},1570        {bin: "0101xxxx", meaning: "Status = SELECT NEXT"},1571        {bin: "0110xxxx", meaning: "Status = TRY ANOTHER INTERFACE"},1572        {bin: "0111xxxx", meaning: "Status = TRY AGAIN"},1573        {bin: "1111xxxx", meaning: "N/A"},1574        {bin: "xxxx1xxx", meaning: "RFU"},1575        {bin: "xxxxx1xx", meaning: "RFU"},1576        {bin: "xxxxxx1x", meaning: "RFU"},1577        {bin: "xxxxxxx1", meaning: "RFU"},1578      ],1579      [1580        {bin: "0000xxxx", meaning: "Start = A"},1581        {bin: "0001xxxx", meaning: "Start = B"},1582        {bin: "0010xxxx", meaning: "Start = C"},1583        {bin: "0011xxxx", meaning: "Start = D"},1584        {bin: "1111xxxx", meaning: "Start = N/A"},1585        {bin: "xxxx1xxx", meaning: "RFU"},1586        {bin: "xxxxx1xx", meaning: "RFU"},1587        {bin: "xxxxxx1x", meaning: "RFU"},1588        {bin: "xxxxxxx1", meaning: "RFU"},1589      ],1590      [1591        {bin: "1111xxxx", meaning: "Online Response Data = N/A"},1592        {bin: "0xxxxxxx", meaning: "RFU"},1593        {bin: "x0xxxxxx", meaning: "RFU"},1594        {bin: "xx0xxxxx", meaning: "RFU"},1595        {bin: "xxx0xxxx", meaning: "RFU"},1596        {bin: "xxxx1xxx", meaning: "RFU"},1597        {bin: "xxxxx1xx", meaning: "RFU"},1598        {bin: "xxxxxx1x", meaning: "RFU"},1599        {bin: "xxxxxxx1", meaning: "RFU"},1600      ],1601      [1602        {bin: "0000xxxx", meaning: "CVM = NO CVM"},1603        {bin: "0001xxxx", meaning: "CVM = OBTAIN SIGNATURE"},1604        {bin: "0010xxxx", meaning: "CVM = ONLINE PIN"},1605        {bin: "0011xxxx", meaning: "CVM = CONFIRMATION CODE VERIFIED"},1606        {bin: "1111xxxx", meaning: "CVM = N/A"},1607        {bin: "xxxx1xxx", meaning: "RFU"},1608        {bin: "xxxxx1xx", meaning: "RFU"},1609        {bin: "xxxxxx1x", meaning: "RFU"},1610        {bin: "xxxxxxx1", meaning: "RFU"},1611      ],1612      [1613        {bin: "1xxxxxxx", meaning: "UI Request on Outcome Present"},1614        {bin: "x1xxxxxx", meaning: "UI Request on Restart Present"},1615        {bin: "xx1xxxxx", meaning: "Data Record Present"},1616        {bin: "xxx1xxxx", meaning: "Discretionary Data Present"},1617        {bin: "xxxx0xxx", meaning: "Receipt = N/A"},1618        {bin: "xxxx1xxx", meaning: "Receipt = YES"},1619        {bin: "xxxxx1xx", meaning: "RFU"},1620        {bin: "xxxxxx1x", meaning: "RFU"},1621        {bin: "xxxxxxx1", meaning: "RFU"},1622      ],1623      [1624        {bin: "1111xxxx", meaning: "Alternate Interface Preference = N/A"},1625        {bin: "0xxxxxxx", meaning: "Alternate Interface Preference = RFU"},1626        {bin: "x0xxxxxx", meaning: "Alternate Interface Preference = RFU"},1627        {bin: "xx0xxxxx", meaning: "Alternate Interface Preference = RFU"},1628        {bin: "xxx0xxxx", meaning: "Alternate Interface Preference = RFU"},1629        {bin: "xxxx1xxx", meaning: "RFU"},1630        {bin: "xxxxx1xx", meaning: "RFU"},1631        {bin: "xxxxxx1x", meaning: "RFU"},1632        {bin: "xxxxxxx1", meaning: "RFU"},1633      ],1634      [1635        {bin: "11111111", meaning: "Field Off Request = N/A"},1636        {bin: "xxxxxxxx", meaning: "Hold time in units of 100 ms"},1637      ],1638      [1639        {bin: "xxxxxxxx", meaning: "Removal Timeoutin units of 100 ms"},1640      ],1641    ],1642    contactlessCVR: [1643      [1644        {bin: "xxxxxxxx", meaning: "BYTE 1: Information for Issuer (Card Decision)"},1645        {bin: "1xxxxxxx", meaning: "Online PIN Required"},1646        {bin: "x1xxxxxx", meaning: "Signature Required"},1647        {bin: "xx00xxxx", meaning: "AAC"},1648        {bin: "xx01xxxx", meaning: "TC"},1649        {bin: "xx10xxxx", meaning: "ARQC"},1650        {bin: "xx11xxxx", meaning: "RFU"},1651        {bin: "xxxx1xxx", meaning: "RFU"},1652        {bin: "xxxxx000", meaning: "Script Counter indicating the number of the script processed during previous contact or contactless transaction"},1653        {bin: "xxxxx001", meaning: "Script Counter indicating the number of the script processed during previous contact or contactless transaction"},1654        {bin: "xxxxx010", meaning: "Script Counter indicating the number of the script processed during previous contact or contactless transaction"},1655        {bin: "xxxxx011", meaning: "Script Counter indicating the number of the script processed during previous contact or contactless transaction"},1656        {bin: "xxxxx100", meaning: "Script Counter indicating the number of the script processed during previous contact or contactless transaction"},1657        {bin: "xxxxx101", meaning: "Script Counter indicating the number of the script processed during previous contact or contactless transaction"},1658        {bin: "xxxxx110", meaning: "Script Counter indicating the number of the script processed during previous contact or contactless transaction"},1659        {bin: "xxxxx111", meaning: "Script Counter indicating the number of the script processed during previous contact or contactless transaction"},1660      ],1661      [1662        {bin: "xxxxxxxx", meaning: "BYTE 2: Compared with Card Risk Management-Card Action Codes (CRM-CAC) and Card Verification Method-Card Action Code (CVM-CAC)"},1663        {bin: "1xxxxxxx", meaning: "Online cryptogram required (if not required, then reader is offlinecapable and supports CDA)"},1664        {bin: "x1xxxxxx", meaning: "Transaction Type required to be processed online with online PIN CVM (e.g., purchase with cash-back, prepaid top-up, etc.)"},1665        {bin: "xx1xxxxx", meaning: "Transaction Type required to be processed offline without any CVM (e.g., refund transaction, prepaid, ticketing, offline balance inquiry, etc.)"},1666        {bin: "xxx1xxxx", meaning: "Domestic Transaction (based on Contactless-ACO setting)"},1667        {bin: "xxxx1xxx", meaning: "International Transaction"},1668        {bin: "xxxxx1xx", meaning: "PIN Try Limit exceeded (Dual-Interface implementation only)"},1669        {bin: "xxxxxx1x", meaning: "Confirmation Code Verification performed"},1670        {bin: "xxxxxxx1", meaning: "Confirmation Code Verification performed and failed"},1671      ],1672      [1673        {bin: "xxxxxxxx", meaning: "BYTE 3: CVM Related Actions"},1674        {bin: "1xxxxxxx", meaning: "CVM Required"},1675        {bin: "x0xxxxxx", meaning: "RFU"},1676        {bin: "xx1xxxxx", meaning: "Consecutive CVM Transaction limit 1 exceeded (CVM-Cons 1)"},1677        {bin: "xxx1xxxx", meaning: "Consecutive CVM Transaction limit 2 exceeded (CVM-Cons 2)"},1678        {bin: "xxxx1xxx", meaning: "Cumulative CVM Transaction Amount limit 1 exceeded (CVM-Cum 1)"},1679        {bin: "xxxxx1xx", meaning: "Cumulative CVM Transaction Amount limit 2 exceeded (CVM-Cum 2)"},1680        {bin: "xxxxxx1x", meaning: "CVM Single Transaction Amount limit 1 exceeded (CVM-STA 1)"},1681        {bin: "xxxxxxx1", meaning: "CVM Single Transaction Amount limit 2 exceeded (CVM-STA 2)"},1682      ],1683      [1684        {bin: "xxxxxxxx", meaning: "BYTE 4: CRM Related Actions"},1685        {bin: "1xxxxxxx", meaning: "CDA failed during previous contactless transaction"},1686        {bin: "x1xxxxxx", meaning: "Last contactless transaction not completed"},1687        {bin: "xx1xxxxx", meaning: "'Go on-line next transaction' was set by contact or contactless application"},1688        {bin: "xxx1xxxx", meaning: "Issuer Authentication failed during previous contact or contactless transaction"},1689        {bin: "xxxx1xxx", meaning: "Script failed on previous contact or contactless transaction"},1690        {bin: "xxxxx1xx", meaning: "Invalid PDOL check"},1691        {bin: "xxxxxx1x", meaning: "PDOL forced online (during GPO)"},1692        {bin: "xxxxxxx1", meaning: "PDOL forced decline (during GPO)"},1693      ],1694      [1695        {bin: "xxxxxxxx", meaning: "BYTE 5: CRM Related Actions"},1696        {bin: "1xxxxxxx", meaning: "Consecutive Contactless Transaction limit exceeded (CL-Cons)"},1697        {bin: "x1xxxxxx", meaning: "Cumulative Contactless Transaction limit exceeded (CL-Cum)"},1698        {bin: "xx1xxxxx", meaning: "Single Contactless Transaction Amount limit exceeded (CL-STA)"},1699        {bin: "xxx1xxxx", meaning: "Lower Consecutive Offline Transaction limit exceeded (LCOL)"},1700        {bin: "xxxx1xxx", meaning: "Upper Consecutive Offline Transaction limit exceeded (UCOL)"},1701        {bin: "xxxxx1xx", meaning: "Lower Cumulative Offline Transaction Amount limit exceeded (LCOA)"},1702        {bin: "xxxxxx1x", meaning: "Upper Cumulative Offline Transaction Amount limit exceeded (UCOA)"},1703        {bin: "xxxxxxx1", meaning: "Single Transaction Amount limit exceeded (STA)"},1704      ],1705      [1706        {bin: "xxxxxxxx", meaning: "BYTE 6: Information for Issuer"},1707        {bin: "xxxx0000", meaning: "ID of PDOL-Decline or PDOL-Online check that forced the transaction to be declined or to go online (Only valid if CL -CVR B4b1 or B4b2 is set)"},1708        {bin: "0000xxxx", meaning: "Transaction profile identifier (0000 by default)"},1709      ],1710      [1711        {bin: "xxxxxxxx", meaning: "BYTE 7: TTQ information for Issuer"},1712        {bin: "1xxxxxxx", meaning: "Contact chip supported"},1713        {bin: "x1xxxxxx", meaning: "Offline-only reader"},1714        {bin: "xx1xxxxx", meaning: "Online PIN supported"},1715        {bin: "xxx1xxxx", meaning: "Signature supported"},1716        {bin: "xxxx1xxx", meaning: "Issuer Update Processing supported"},1717        {bin: "xxxxx0xx", meaning: "RFU"},1718        {bin: "xxxxxx0x", meaning: "RFU"},1719        {bin: "xxxxxxx0", meaning: "RFU"},1720      ],1721      [1722        {bin: "xxxxxxxx", meaning: "BYTE 8: RFU"},1723      ],1724    ],1725    cpr: [1726      [1727        {bin: "1xxxxxxx", meaning: "Online PIN required"},1728        {bin: "x1xxxxxx", meaning: "Signature required"},1729        {bin: "xx1xxxxx", meaning: "RFU"},1730        {bin: "xxx1xxxx", meaning: "Consumer Device CVM Performed"},1731        {bin: "xxxx0xxx", meaning: "RFU"},1732        {bin: "xxxxx0xx", meaning: "RFU"},1733        {bin: "xxxxxx0x", meaning: "RFU"},1734        {bin: "xxxxxxx0", meaning: "RFU"},1735      ],1736      [1737        {bin: "1xxxxxxx", meaning: "Switch other interface if unable to process online"},1738        {bin: "x1xxxxxx", meaning: "Process online if CDA failed"},1739        {bin: "xx1xxxxx", meaning: "Decline/switch to other interface if CDA failed"},1740        {bin: "xxx1xxxx", meaning: "Issuer Update Processing supported"},1741        {bin: "xxxx1xxx", meaning: "Process online if card expired"},1742        {bin: "xxxxx1xx", meaning: "Decline if card expired"},1743        {bin: "xxxxxx1x", meaning: "CVM Fallback to Signature allowed"},1744        {bin: "xxxxxxx1", meaning: "CVM Fallback to No CVM allowed"},1745      ],1746    ],1747  },1748  ...calcVarIndex.py
Source:calcVarIndex.py  
1"""2Author: å
¬ä¼å·-ç®æ³è¿é¶3塿¹åç®±ï¼è®¡ç®PSIãWOEãIVçææ 4"""5import random6import numpy as np7import pandas as pd8import pandas.io.sql as sqlio9from sklearn.model_selection import train_test_split10from matplotlib.ticker import FuncFormatter11from collections import Counter12from scipy import stats13from sklearn import metrics14import io15import datetime16from sqlalchemy import create_engine17import matplotlib.pyplot as plt18def get_char_and_num_var_names(df, excluses=None):19    '''20    åºå离æ£ãè¿ç»åé21    @df:dataframe22    @excluses:ä¸è¿è¡åºåçåå23    '''24    if excluses is not None:25        df = df.drop(excluses, axis=1)26        27    var_types = df.dtypes28    var_types_index = var_types.index29    char_var_names,num_var_names = [], []30    for i in range(len(var_types)):31        if var_types[i] == np.datetime64:32            break33        elif var_types[i] == np.object:34            char_var_names.append(var_types_index[i])35        else:36            num_var_names.append(var_types_index[i])37    return char_var_names, num_var_names38def transformInterval(bingroup):39    '''è¿ç»åéåç®±åºé´å¤ç---str转为pd.Interval/set/list/float'''40    if type(bingroup)!=str:41        return 'éå符串'42    43    def f(bingroup, left_side,right_side,closed):44        left =bingroup[bingroup.find(left_side)+1:bingroup.find(right_side)].split(',')[0]45        if left=='-â':46            left = -np.inf47        else:48            left = float(left)49            50        right=bingroup[bingroup.find(left_side)+1:bingroup.find(right_side)].split(',')[1]51        if right=='+â':52            right = np.inf53        else:54            right = float(right)55        56        if 'or' not in bingroup: #æ ¼å¼1 æ£å¸¸å¼--è¿åpd.Interval57            return pd.Interval(left,right,closed)58        else: # æ ¼å¼2 æ£å¸¸å¼ï¼åºé´ï¼+å¼å¸¸å¼(éå) --è¿ålist[pd.Interval,set]59            return [pd.Interval(left,right,closed),60                   {float(i) for i in bingroup[bingroup.find('{')+1:bingroup.find('}')].split(',')}]61        62    try:63        bingroup = bingroup.replace(' ','')64        bingroup = bingroup.replace('ï¼',',')65        66        if '(' in bingroup and ']' in bingroup:67            return f(bingroup,'(',']',closed='right')68        elif '(' in bingroup and ')' in bingroup:69            return f(bingroup,'(',')',closed='neither')70        elif '[' in bingroup and ')' in bingroup:71            return f(bingroup,'[',')',closed='left')72        elif '[' in bingroup and ']' in bingroup:73            return f(bingroup,'[',']',closed='both')74        elif '{' in bingroup and '}' in bingroup: #æ ¼å¼3ï¼å¼å¸¸å¼éå---è¿åset75            return {float(i) for i in bingroup[bingroup.find('{')+1:bingroup.find('}')].split(',')}76        else:#æ ¼å¼4å个å¼å¸¸å¼æå个æ£å¸¸å¼---è¿åint77            return int(float(bingroup.split('_')[-1]))78    except:79        return 'åç¬¦ä¸²ä¸ªæ°æè¯¯'80# 离æ£åç®±81def varChi2bin_char(df, gbflag, abnor, char_var_names):82    '''83    离æ£åéå表å
çç¹å¾åç®±ï¼æå°10个ç¹å¾84   85    '''86    rs = pd.DataFrame()87    t = len(char_var_names)//1088    if t ==0:t=189    i=090    for char_var_name in char_var_names:91        if df[char_var_name].unique().size<=150:92            char_bin = CharVarChi2Bin(df, char_var_name, gbflag, abnor, BinMax=12)93            rs = rs.append(char_bin)94        i+=195        if i%t==0:96            print("* ",end="")97    print("")98    return rs99def CharVarChi2Bin(df,varname,gbflag,abnor=[],BinMax=10,BinPcntMin=0.03):100    '''101    离æ£ç¹å¾å¡æ¹åç®±102    @df:dataframe103    @varname:è¦åç®±çååå表104    @gbflag:æ ç¾105    @abnor:ç¹æ®å¼106    @binMax:æå¤§åç®±æ°107    @BinPctMin:æ¯ä¸ªåç®±çæå°æ ·æ¬å æ¯108    '''109    # æ£å¸¸æ°æ®æ ·æ¬110    df_nor = df[~df[varname].isin(abnor)]111    merge_bin = initBin(df_nor,varname,gbflag) # æ£å¸¸æ°æ®æ ·æ¬åå§ååç®±ï¼æç
§åæ ·æ¬å æ¯æåº112    merge_bin = matchBin(merge_bin,BinMax,BinPcntMin) # æ£å¸¸æ°æ®æ ·æ¬åå¹¶åç®±ï¼ç¥é满足æ¡ä»¶113    114    # ç¹æ®å¼æ ·æ¬115    df_abnor = df[df[varname].isin(abnor)]116    result_abnor = initBin(df_abnor,varname,gbflag) # ç¹æ®å¼æ°æ®æ ·æ¬åç®±117    118    # åå¹¶119    result = pd.concat([merge_bin,result_abnor],axis=0)120    result.reset_index(inplace=True)121    result.rename(columns={varname:'bingroup'},inplace=True)122    result.insert(0,'varname',varname)123    124    result = idCharBin(result)125    return result126# 离æ£åéåå§ååç®±127def initBin(df,varname,gbflag,sort='bad_percent'):128    '''129    åå§ååç®±130    @df:dataframe131    @varname:è¦åç®±çååå表132    @gbflag:æ ç¾133    @sort:æåºçåå134    '''135    print([varname,gbflag])136    print(df[[varname,gbflag]])137    init_bin = df[[varname,gbflag]].groupby(varname).agg(['count','sum'])[gbflag]138    init_bin.columns = ['total_counts','bad_counts']139    init_bin.insert(1,'good_counts',init_bin.total_counts-init_bin.bad_counts)140    init_bin['bad_percent'] = init_bin.bad_counts/init_bin.total_counts141    142    if sort=='bad_percent':143        init_bin.sort_values('bad_percent', inplace=True) # ç¦»æ£æ°æ®åå§ååç®±ï¼æç
§åæ ·æ¬å æ¯æåº144    else:# å¹´é¾åæ°æ®åå§ååç®±145        init_bin.sort_index(inplace=True) # æç
§æ°å¼å¤§å°æåº146        var_list = list(init_bin.index.insert(0,'-â'))147        var_list[-1] = '+â'148        init_bin.index = ['({},{})'.format(var_list[i],var_list[i+1]) for i in range(len(var_list)-1)]149        150    init_bin.drop(columns=['bad_percent'],inplace=True)151    return init_bin152def matchBin(df,BinMax,BinPcntMin):153    '''154    夿æ£å¸¸æ ·æ¬åç®±æ¯å¦ç¬¦åæ¡ä»¶155    @df:dataframe156    @binMax:æå¤§åç®±æ°157    @BinPctMin:æ¯ä¸ªåç®±çæå°æ ·æ¬å æ¯158    '''159    # æ£æ¥åç»æ¯å¦<=BinMax160    while len(df)>BinMax:161        minChi2=None162        for i in range(len(df.index)-1):163            chi2 = calcChi2(df.iloc[i:i+2]) #åå«è®¡ç®ç¸é»ä¸¤ç»ç塿¹å¼164            if minChi2 is None or minChi2>chi2:165                minChi2=chi2166                minIndex=i167        df = mergeBin(df, minIndex, minIndex+1)168        169        # æ£æ¥æ¯ä¸ªåç»æ¯å¦å
åæ¶å«å¥½æ ·æ¬ååæ ·æ¬170        while len(df)>1 and len(df[(df['good_counts']==0) | (df['bad_counts']==0)])!=0:171            #è¥åå¨åªå
å«å¥½æ ·æ¬/åæ ·æ¬çåç»ï¼ä¸åç»>1172            to_bin = df[(df['good_counts']==0)|(df['bad_counts']==0)].head(1)173            174            for i in range(len(df.index.tolist())):175                if to_bin.index[0] == df.index.tolist()[i]:176                    if i == 0:#第ä¸ä¸ªåç»éè¦åå¹¶177                        df = mergeBin(df, i, i+1)178                        break179                    elif i == len(df.index.tolist())-1:#æåä¸ä¸ªåç»éè¦åå¹¶180                        df = mergeBin(df, i-1, i)181                        break182                    else:#ä¸é´åç»éè¦åå¹¶183                        chi2_f = calcChi2(df.iloc[i-1:i+1])184                        chi2_b = calcChi2(df.iloc[i:i+2])185                        if chi2_f<=chi2_b:#ä¸åä¸ä¸ªåç»ç塿¹å¼æ´å°186                            df = mergeBin(df, i-1, i)187                            break188                            189                            190        # æ£æ¥æ¯ä¸ªåç»çæ ·æ¬å æ¯æ¯å¦>=BinPcntMin191        while len(df)>1 and len(df[df.total_counts/df.total_counts.sum()<BinPcntMin])!=0:192            to_bin = df[df.total_counts/df.total_counts.sum()<BinPcntMin].head(1)193            194            for i in range(len(df.index.tolist())):195                if to_bin.index[0] == df.index.tolist()[i]:196                    if i == 0:#第ä¸ä¸ªåç»éè¦åå¹¶197                        df = mergeBin(df, i , i+1)198                        break199                    elif i ==len(df.index.tolist())-1:#æåä¸ä¸ªåç»éè¦åå¹¶200                        df = mergeBin(df, i-1, i)201                        break202                    else:#ä¸é´åç»éè¦åå¹¶203                        chi2_f = calcChi2(df.iloc[i-1:i+1])204                        chi2_b = calcChi2(df.iloc[i:i+2])205                        if chi2_f<chi2_b:#ä¸åä¸ä¸ªåç»ç塿¹å¼æ´å°206                            df = mergeBin(df, i-1, i)207                            break208                        else:#ä¸åä¸ä¸ªåç»ç塿¹å¼æ´å°209                            df = mergeBin(df, i, i+1)210                            break211    return df212def varChi2Bin_num(df, gbflag, abnor, num_var_names):213    '''214    对è¿ç»åéå表å
çç¹å¾è¿è¡åç®±215   @df:dataframe216   @gbflag:æ ç¾217   @abnor:ç¹æ®å¼218   @num_var_names:è¿è¡åç®±çååå表219    '''220    rs = pd.DataFrame()221    t = len(num_var_names)//10222    if t==0:t=1223    i=0224    for num_var_name in num_var_names:225        num_bins = NumVarChi2Bin(df,num_var_name, gbflag, abnor, BinMax=12)226        rs = rs.append(num_bins)227        i+=1228        if i%t==0:229            print("*",end="")230    print("")231    return rs232# è¿ç»åéåç®±233def NumVarChi2Bin(df,varname,gbflag,abnor=[],InitGroup=100,BinMax=10,BinPcntMin=0.03,check=True):234    '''235    è¿ç»åéåç®±236    @df:dataframe237    @gbflag:æ ç¾238    @abnor:ç¹æ®å¼å表239    @InitGroup:ç¹å¾ä¸ªæ°240    @BinMax:æå¤§åç®±æ°241    @BinPcntMin:æ¯ç®±çæå°å æ¯242    '''243    df_nor = df[~df[varname].isin(abnor)]244    if len(Counter(df[varname]))>100:245        merge_bin = initNumBin(df_nor,varname,gbflag,InitGroup) #çé¢,ææ°å¼å¤§å°æåº246    else:247        merge_bin = initBin(df_nor,varname,gbflag,sort='num')248    merge_bin = matchBin(merge_bin,BinMax,BinPcntMin) #æ£å¸¸æ ·æ¬åå¹¶åç®±ï¼ç¥é满足æ¡ä»¶249    if check:250        merge_bin = check_bad_ratio_order(merge_bin,varname)251    merge_bin.insert(0,'bingroup',['({},{})'.format(i.split(',')[0].split('(')[1], i.split(',')[-1].split(']')[0]) for i in merge_bin.index])252    merge_bin.reset_index(drop=True, inplace=True)253    254    # ç¹æ®å¼æ ·æ¬255    df_abnor = df[df[varname].isin(abnor)]256    result_abnor = initBin(df_abnor,varname,gbflag) #ç¹æ®å¼æ ·æ¬åç®±257    result_abnor.reset_index(inplace=True)258    result_abnor.rename(columns={'index':'bingroup',varname:'bingroup'}, inplace=True)259    260    # åå¹¶261    result = pd.concat([merge_bin,result_abnor],axis=0)262    result.reset_index(drop=True,inplace=True)263    result.insert(0,'varname',varname)264    265    result = idNumBin(result)266    return result267    268def initNumBin(df,varname,gbflag,InitGroup):269    '''270    è¿ç»åæ°æ®åå§ååç®±(çé¢åç®±)271    @df:dataframe272    @varname:åéå273    @gbflag:æ ç¾274    @InitGroup:åå§ååç®±æ°275    '''276    init_bin = pd.DataFrame(df[[varname,gbflag]])277    print(init_bin[varname])278    print('-------------------')279    print(InitGroup)280    init_bin[varname]=pd.qcut(init_bin[varname],InitGroup,precision=4,duplicates='drop')281    init_bin=init_bin.groupby(varname).agg(['count','sum'])[gbflag].sort_index()282    init_bin.columns=['total_counts','bad_counts']283    init_bin.insert(1,'good_counts',init_bin.total_counts-init_bin.bad_counts)284    init_bin.index=init_bin.index.astype(str)285    286    # åºé´å¤ç(åå为â)287    init_bin.rename(index={288        init_bin.index[0]:'(-â,{}]'.format(init_bin.index[0].split(',')[-1].split(']')[0]),289        init_bin.index[-1]:'({},+â]'.format(init_bin.index[-1].split(',')[0].split('(')[1])},inplace=True)290    291    return init_bin292def charVarBinCount(df_bin,dataSet,gbflag,varname='varname',bingroups='bingroups'):293    '''294    ç»åºåç®±ï¼è®¡ç®ç¦»æ£åéæ ·æ¬è®¡æ°295    @df_bin:åç®±åçåºé´ååéå['varname','groups']296    @dataSet:è¿è¡è®¡æ°çdataframe297    @gbflag:æ ç¾298    @varname:åéå299    @bingroups:åç®±åºé´300    '''301    allVarBin = pd.DataFrame()302    for var in pd.unique(df_bin[varname]).tolist():303        print('--------------'+var+'--------------')304        varData = pd.DataFrame(dataSet[[var,gbflag]])305        varBin = pd.DataFrame(df_bin[df_bin[varname]==var])306        varBin['binList']=varBin[bingroups].apply(lambda x:[i for i in str(x)307[str(x).find('{')+1:str(x).find('}')].split(',')])308        varBin['good_counts']=varBin['binList'].apply(lambda x:varData[(varData[gbflag]==0)&309(varData[var].isin(x))].count()[0])310        varBin['bad_counts']=varBin['binList'].apply(lambda x:varData[(varData[gbflag]==1)&311(varData[var].isin(x))].count()[0])312        varBin['total_counts']=varBin['good_counts']+varBin['bad_counts']313        314        if varBin['total_counts'].sum()==dataSet.shape[0]:315            pass316        elif varBin['total_counts'].sum()==dataSet.shape[0]:317            print('该åéåç®±æéå ï¼è¯·è°æ´')318            print('sum = ',varBin['total_counts'].sum())319        else:#æ°å±æ§å¨æµè¯éåºç°ï¼åç®±æéæ¼320            print('该åéåç®±æéæ¼ï¼è¯·æ³¨æ')321            s=set()322            for i in varBin.index:323                s=s.union(set(varBin['binList'].loc[i]))324            325            varData_add=varData[~varData[var].isin(s)]326            print(pd.unique(varData_add[var]))327            varBin_add=\328            varData_add[var][varData_add[gbflag]==0].value_counts().to_frame().rename(columns={var:'good_counts'}).join(329            varData_add[var][varData_add[gbflag]==1].value_counts().to_frame().rename(columns={var:'bad_counts'}),330                how='outer').replace(np.nan,0).reset_index().rename(columns={'index':bingroups})331            varBin_add['good_counts'] = varBin_add['good_counts'].astype(np.int64)332            varBin_add['bad_counts'] = varBin_add['bad_counts'].astype(np.int64)333            varBin_add['total_counts'] = varBin_add['good_counts'] + varBin_add['bad_counts']334            varBin_add[varname]=var335            varBin=varBin.append(varBin_add)336            print('sum = ',varBin['total_counts'].sum())337            338        print(varBin[['bingroups','good_counts','bad_counts','total_counts']])339        varBin.drop(columns=['binList'],inplace=True)340        allVarBin=allVarBin.append(varBin)341    return allVarBin342def numVarBinCount(df_bin,dataSet,gbflag,abnor,varname='varname',bingroups='bingroups',transform_interval=1):343    '''344    ç»åºåç®±ï¼è®¡ç®è¿ç»åéæ ·æ¬è®¡æ°345    @df_bin:åç®±åçåºé´ååéå['varname','groups']346    @dataSet:è¿è¡è®¡æ°çdataframe347    @gbflag:æ ç¾348    @abnor:ç¹æ®å¼å表349    @varname:åéå350    @bingroups:åç®±åºé´351    @transform_interval:åç®±å¼å¤çæ å¿352    '''353    allVarBin = pd.DataFrame()354    for var in pd.unique(df_bin[varname]).tolist():355        print('---------------'+var+'---------------')356        varData=pd.DataFrame(dataSet[[var,gbflag]])357        varBin=pd.DataFrame(df_bin[df_bin[varname]==var])358        if transform_interval:359            varBin['interval']=varBin[bingroups].apply(transformInterval)360        else:361            varBin['interval']=varBin[bingroups]362        363        varBin['good_counts'],varBin['bad_counts']=0,0364        365        abnor_exist=[]366        for i in varBin.index:367            if isinstance(varBin.interval.loc[i],pd.Interval): #æ£å¸¸å¼368                if varBin.interval.loc[i].closed=='right': #(left,right]369                    varBin.loc[i,'good_counts']=varData[370                        (varData[gbflag]==0)&371                        (varData[var]>varBin.interval.loc[i].left)&372                        (varData[var]<=varBin.interval.loc[i].right)&373                        (~varData[var].isin(abnor))374                    ].count([0])375                    varBin.loc[i,'bad_counts']=varData[376                        (varData[gbflag]==1)&377                        (varData[var]>varBin.interval.loc[i].left)&378                        (varData[var]<=varBin.interval.loc[i].right)&379                        (~varData[var].isin(abnor))380                    ].count([0])381                elif varBin.interval.loc[i].closed=='left': #[left,right)382                    varBin.loc[i,'good_counts']=varData[383                        (varData[gbflag]==0)&384                        (varData[var]>=varBin.interval.loc[i].left)&385                        (varData[var]<varBin.interval.loc[i].right)&386                        (~varData[var].isin(abnor))387                    ].counts([0])388                    varBin.loc[i,'bad_count']=varData[389                        (varData[gbflag]==1)&390                        (varData[var]>=varBin.interval.loc[i].left)&391                        (varData[var]<varData.interval.loc[i].right)&392                        (~varData[var].isin(abnor))393                    ].count()[0]394                elif varBin.interval.loc[i].closed=='both': #[left,right]395                    varBin.loc[i,'good_counts']=varData[396                        (varData[gbflag]==0)&397                        (varData[var]>=varBin.interval.loc[i].left)&398                        (varData[var]<=varBin.interval.loc[i].right)&399                        (~varData[var].isin(abnor))400                    ].count()[0]401                    varBin.loc[i,'bad_counts']=varData[402                        (varData[gbflag]==1)&403                        (varData[var]>=varBin.interval.loc[i].left)&404                        (varData[var]<=varBin.interval.loc[i].right)&405                        (~varData[var].isin(abnor))406                    ].count()[0]407                else: #(left,right)408                    varBin.loc[i,'good_counts']=varData[409                        (varData[gbflag]==0)&410                        (varData[var]>varBin.interval.loc[i].left)&411                        (varData[var]<varBin.interval.loc[i].right)&412                        (~varData[var].isin(abnor))413                    ].count()[0]414                    varBin.loc[i,'bad_counts']=varData[415                        (varData[gbflag]==1)&416                        (varData[var]>varBin.interval.loc[i].left)&417                        (varData[var]<varBin.interval.loc[i].right)&418                        (~varData[var].isin(abnor))419                    ].count()[0]420                    421            elif isinstance(varBin.interval.loc[i],set): #å¼å¸¸å¼éå422                abnor_exist.extend(varBin.interval.loc[i]) #å·²æå¼å¸¸å¼423                424                varBin.loc[i,'good_counts']=varData[425                    (varData[gbflag]==0)&426                    (varData[var].isin(varBin.interval.loc[i]))427                ].count()[0]428                varBin.loc[i,'bad_counts']=varData[429                    (varData[gbflag]==1)&430                    (varData[var].isin(varBin.interval.loc[i]))431                ].count()[0]432        433            elif isinstance(varBin.interval.loc[i],list): #æ£å¸¸å¼+å¼å¸¸å¼434                abnor_exist.extend(varBin).loc[i][1] #å·²æå¼å¸¸å¼435                varBin.loc[i,'good_counts']=varData[436                    ((varData[gbflag]==0)&(varData[var].apply(lambda x:x in varBin,interval.loc[i][0] and x not in abnor)))437                    |438                    ((varData[gbflag]==0)&(varData[var].isin(varBin.interval.loc[i])))439                ].count()[0]440                varBin.loc[i,'bad_counts']=varData[441                    ((varData[gbflag]==1)&(varData[var].apply(lambda x:x in varBin,interval.loc[i][0] and x not in abnor)))442                    |443                    ((varData[gbflag]==1)&(varData[var].isin(varBin.interval.loc[i])))444                ].count()[0]445            else: #å个å¼ï¼å¯è½æ¯å¼å¸¸å¼ï¼å¯è½æ¯æ£å¸¸å¼446                if varBin.interval.loc[i] in abnor:447                    abnor_exist.append(varBin.interval.loc[i]) #å·²æå¼å¸¸å¼448                varBin.loc[i,'good_counts']=varData[449                    (varData[gbflag]==0)&450                    (varData[var]==varBin.interval.loc[i])451                ].count()[0]452                varBin.loc[i,'bad_counts']=varData[453                    (varData[gbflag]==1)&454                    (varData[var]==varBin.interval.loc[i])455                ].count()[0]456            varBin['total_counts']=varBin['good_counts']+varBin['bad_counts']457        if varBin['total_counts'].sum()==dataSet.shape[0]:458            pass459        elif varBin['total_counts'].sum()>dataSet.shape[0]:460            print('该åéåç®±æéå ï¼è¯·è°æ´')461            print('sum = ', varBin['total_counts'].sum())462        else: #åç®±ä¸å®æ´ï¼æéæ¼åé463            print('该åéåç®±(å¼å¸¸å¼)æéæ¼ï¼è¯·æ³¨æï¼')464            varData_add=varData[varData[var].isin(set(abnor)-set(abnor_exist))]465            print(pd.unique(varData_add[var]))466            varBin_add=\467            varData_add[var][varData_add[gbflag]==0].value_counts().to_frame().rename(columns={var:'good_counts'}).join(468            varData_add[var][varData_add[gbflag]==1].value_counts().to_frame().rename(columns={var:'bad_counts'}),469            how='outer').replace(np.nan,0).reset_index().rename(columns={'index':bingroups})470            varBin_add['good_counts'] = varBin_add['good_counts'].astype(np.int64)471            varBin_add['bad_counts'] = varBin_add['bad_counts'].astype(np.int64)472            varBin_add['total_counts'] = varBin_add['good_counts'] + varBin_add['bad_counts']473            varBin_add[varname]=var474            varBin=varBin.append(varBin_add)475            print('sum = ',varBin['total_counts'].sum())476        print(varBin[[bingroups,'interval','good_counts','bad_counts','total_counts']])477        varBin.drop(columns=['interval'],inplace=True)478        allVarBin=allVarBin.append(varBin)479    return allVarBin480def calcVarIndex(df,version='',var_col='varname',good_col='good_counts',bad_col='bad_counts'):481    '''482    计ç®åéçivãksãwoe483    @df:åç®±åºé´ä¸å¥½å个æ°484    @version:çæ¬485    @var_col:åéåçåå486    @good_col:好堿¯çåå487    @bad_col:åå æ¯çåå488    '''489    detail,result = pd.DataFrame(),pd.DataFrame()490    for var in pd.unique(df[var_col]).tolist():491        vardf = pd.DataFrame(df[df[var_col]==var])492        # datail493        vardf[['good_pct','bad_pct']] = vardf[[good_col,bad_col]]/vardf[[good_col,bad_col]].sum() #计ç®å æ¯494        vardf[['good_cum_pct','bad_cum_pct']] = vardf[['good_pct','bad_pct']].cumsum() #计ç®ç´¯è®¡å æ¯495        496        vardf['ks'] = abs(vardf['good_cum_pct']-vardf['bad_cum_pct']) #计ç®ks497        498        vardf['woe'] = (499            (vardf[bad_col].replace(0,1)/vardf[bad_col].sum())/(vardf[good_col].replace(0,1)/vardf[good_col].sum())500        ).apply(lambda x:np.log(x)) #计ç®woe501        502        vardf['iv'] = (503            (vardf[bad_col].replace(0,1)/vardf[bad_col].sum())-(vardf[good_col].replace(0,1)/vardf[good_col].sum())504        ) * vardf['woe'] #计ç®iv505        506        detail = detail.append(vardf)507        508        # result509        varRst = vardf[[good_col, bad_col]].sum().astype(int).to_frame().T510        varRst.insert(0, var_col, var)511        varRst['iv'] = vardf['iv'].sum()512        varRst['ks'] = vardf['ks'].max()513        result = result.append(varRst)514       515    return detail,result516def calcVarPSI(df_train,df_test,version='',var_col='varname',bin_col='bingroups',total_col='bin_counts'):517    '''518    计ç®åéçpsi519    @df_train:è®ç»éæ°æ®520    @df_test:æµè¯éæ°æ®521    @version:çæ¬522    @var_col:åéå523    @bin_col:åç®±å¼524    @total_col:ç®±åæ°é525    '''526    df = df_train[[var_col,bin_col,total_col]].merge(df_test[[var_col,bin_col,total_col]],how='outer',on=[var_col,bin_col],suffixes=('_train','_test'))527    df.replace(np.nan,0,inplace=True)528    df[total_col+'_train'] = df[total_col+'_train'].astype(np.int64)529    df[total_col+'_test'] = df[total_col+'_test'].astype(np.int64)530    531    detail,result = pd.DataFrame(),pd.DataFrame()532    533    for var in pd.unique(df[var_col]).tolist():534        vardf =pd.DataFrame(df[df[var_col]==var])535        vardf,varPSI = calcPSI(vardf,bin_col,total_col+'_train',total_col+'_test',version) # 计ç®å个åéçpsi_detailåpsi536        vardf.insert(0,var_col,var)537        detail = detail.append(vardf)538        result = result.append([[var,varPSI]])539    result.columns = ['varname','psi']540    return detail,result541def calcPSI(df,bin_col,train_bin_counts,test_bin_counts,version):542    df['train_total_counts'] = df[train_bin_counts].sum()543    df['test_total_counts'] = df[test_bin_counts].sum()544    df[['train_bin_pct','test_bin_pct']] = df[[train_bin_counts,test_bin_counts]]/df[[train_bin_counts,test_bin_counts]].sum()545    # psiææ è®¡ç®546    a = df['train_bin_pct'].replace(0,1/df['train_total_counts'].iloc[0])547    e = df['test_bin_pct'].replace(0,1/df['test_total_counts'].iloc[0])548    df['a-e'] = a - e549    df['a/e'] = a/e550    df['log_a/e'] = np.log(df['a/e'].values)551    df['index'] = df['a-e'] * df['log_a/e']552    553    df = df[[bin_col,'train_total_counts',train_bin_counts,'train_bin_pct',554             'test_total_counts',test_bin_counts,'test_bin_pct','a-e','a/e','log_a/e','index']]555    tm = datetime.datetime.now()556    df['version'] = version557    df['tmstamp'] = tm558    PSI = df['index'].sum()559    return df, PSI560def calcCorr(dataSet, var_list, abnor, replace='delete'):561    '''562    计ç®ç¸å
³æ§ç³»æ°563    @dataSet:è¿è¡è®¡ç®çdataframe564    @var_list:è¿è¡è®¡ç®çåå565    @abnor:ç¹æ®å¼å表566    '''567    var_list = sorted(var_list) #æåéåç§°æåº568    data=dataSet[var_list][:]569    570    print('æ£å¨å¤çå¼å¸¸å¼...')571    if replace=='delete':572        for i in abnor:573            data.replace(i, np.nan, inplace=True)574    elif replace=='0':575        for i in abnor:576            data.replace(i, 0, inplace=True)577    print('æ£å¨çæç¸å
³æ§ç³»æ°æ¹éµ...')578    corr_matrix = data.corr()579    print('å·²çæ')580    581    #åä¸è§éµæ°æ®582    corr_df=pd.DataFrame()583    for i in range(len(var_list)-1):584        for j in range(i+1, len(var_list)):585            corr_df = corr_df.append([[586                var_list[i],587                var_list[j],588                corr_matrix.loc[var_list[i],var_list[j]]589            ]])590    corr_df.reset_index(drop=True, inplace=True)591    corr_df.columns = ['var1', 'var2', 'r']592    return corr_df593def filterVarIv(df_iv, temp, corr, threshold_r):594    '''595    æ ¹æ®ivåé¤ç¸å
³æ§é«çåé596    @df_iv:ivå¼597    @temp:æè¿è¡ç¸å
³æ§è®¡ç®çåéå598    @corr:åéç¸å
³æ§599    @threshold_r:ç¸å
³æ§éå¼600    '''601    corr = corr[corr.r > threshold_r][:]602    corr.sort_values('r', ascending=False, inplace=True)603    604    corr['iv1'] = pd.Series([df_iv[df_iv.varname == i].iv.tolist() for i in corr.var1])605    corr['iv2'] = pd.Series([df_iv[df_iv.varname == i].iv.tolist() for i in corr.var2])606    607    drop_list = []608    609    while len(corr)>=1:610        group = corr.iloc[0]611        if group.iv1 >= group.iv2: #å é¤ivä½çæ°æ®(å é¤åé2)612            drop_list.append(group.var2)613            corr = corr[~(corr.var1.isin([group.var2])|corr.var2.isin([group.var2]))]614        else: #å é¤åé1615            drop_list.append(group.var1)616            corr = corr[~(corr.var1.isin([group.var1])|corr.var2.isin([group.var1]))]617        print('personr( {}, {} ) = {} åé¤:{}'.format(group.var1,group.var2,round(group.r,2),drop_list[-1])) # æå°çéè¿ç¨618    619    stay_list = list(set(temp)-set(drop_list))620    621    return stay_list, drop_list622def woe_tranform_data(data,id_list,gbflag,num_adjust,abnor,char_adjust):623    '''624    å©ç¨woeå¯¹æ°æ®è¿è¡ç¼ç 625    @id_list:æ°æ®idååå626    @gbflag:æ ç¾627    @num_adjust:è¿ç»åéåç®±åwoeå¼628    @abnor:ç¹æ®å¼å表629    @char_adjust:离æ£åéåç®±åwoeå¼630    '''631    # è®ç»éwoeç¼ç --è¿ç»632    if num_adjust is not None:633        woe_num = numWoeEncoder(df_woe=num_adjust,634                               dataSet=data,635                               dataSet_id=id_list,636                               gbflag=gbflag,637                               abnor=abnor)638        if woe_num.isnull().sum().sum()>0:639            print('num exception')640    641    # è®ç»éwoeç¼ç --离æ£642    if char_adjust is not None:643        woe_char = charWoeEncoder(df_woe=char_adjust,644                                 dataSet=data,645                                 dataSet_id=id_list,646                                 gbflag=gbflag)647        if woe_char.isnull().sum().sum()>0:648            print('char exception')649    650    if num_adjust is not None and char_adjust is not None:651        all_woe=woe_num.merge(woe_char,on=id_list+[gbflag])652        return all_woe653    elif num_adjust is not None:654        return woe_num655    elif char_adjust is not None:656        return woe_char  # æ æ¤åé657    else:658        return None659# 离æ£660def charWoeEncoder(df_woe,dataSet,dataSet_id,gbflag):661    '''662    离æ£åéwoeæ å°663    @df_woe:åéåç®±åwoeå¼664    @dataSet:è¿è¡æ å°çæ°æ®665    @dataSet_id:æ°æ®idååå666    @gbflag:æ ç¾667    '''668    dataSet.reset_index(drop=True, inplace=True)669    allCharWoeEncode = pd.DataFrame(dataSet[dataSet_id])670    671    for var in pd.unique(df_woe.varname).tolist():672        allCharWoeEncode=allCharWoeEncode.join(singleCharVarWoeEncoder(var,df_woe,dataSet))673        allCharWoeEncode[var].replace(np.nan,allCharWoeEncode[var].max(),inplace=True)674        # æå°dataSet空woe675        print(allCharWoeEncode[var][allCharWoeEncode[var].isnull()])676    allCharWoeEncode=allCharWoeEncode.join(dataSet[gbflag])677    return allCharWoeEncode678# è¿ç»å679def numWoeEncoder(df_woe,dataSet,dataSet_id,gbflag,abnor):680    '''681    è¿ç»åéwoeæ å°682    @df_woe:åéåç®±åwoeå¼683    @dataSet:è¿è¡æ å°çæ°æ®684    @dataSet_id:æ°æ®idååå685    @gbflag:æ ç¾686    '''687    dataSet.reset_index(drop=True,inplace=True)688    allNumWoeEncode = pd.DataFrame(dataSet[dataSet_id])689    # allNumWoeEncode = pd.DataFrame()690    691    for var in pd.unique(df_woe.varname).tolist():692        allNumWoeEncode = allNumWoeEncode.join(singleNumVarWoeEncoder(var,df_woe,dataSet,abnor))693        allNumWoeEncode[var].replace(np.nan,allNumWoeEncode[var].max(),inplace=True)694        # æå°dataSet空woe695        print(allNumWoeEncode[var][allNumWoeEncode[var].isnull()])696    allNumWoeEncode=allNumWoeEncode.join(dataSet[gbflag])697    return allNumWoeEncode698def singleNumVarWoeEncoder(var,df_woe,dataSet,abnor):699    '''700    è¿ç»åéwoeæ å°701    @var:åéå702    @df_woe:åéåç®±åwoeå¼703    @dataSet:è¿è¡æ å°çæ°æ®704    @abnor:ç¹æ®å¼å表705    '''706    print('-------------'+var+'-------------')707    varData=pd.DataFrame(dataSet[var])708    varData['woe']=np.nan709    710    varWoe = pd.DataFrame(df_woe[df_woe.varname==var])711    varWoe['interval']=varWoe['bingroups'].apply(transformInterval)712    print(varWoe[['bingroups','interval','woe']])713    print(varWoe.dtypes)714    715    varWoeEncode = pd.DataFrame()716    for i in range(len(varWoe)):717        # å¤æè¯¥åç®±æ¯å¦ä¸ºinterval718        if isinstance(varWoe.interval.iloc[i],pd.Interval):719            # 夿intervalçå¼é720            if varWoe.interval.iloc[i].closed=='right': # å·¦å¼å³é721                varWoeEncode=varWoeEncode.append(pd.DataFrame(722                varData[723                    (varData[var]>varWoe.interval.iloc[i].left)&724                    (varData[var]<=varWoe.interval.iloc[i].right)&725                    (~varData[var].isin(abnor))726                ].woe.replace(np.nan,varWoe.woe.iloc[i])727                ))728            elif varWoe.interval.iloc[i].closed=='left': #å·¦éå³å¼729                varWoeEncode=varWoeEncode.append(pd.DataFrame(730                varData[731                    (varData[var]>=varWoe.interval.iloc[i].left)&732                    (varData[var]<varWoe.interval.iloc[i].right)&733                    (~varData[var].isin(abnor))734                ].woe.replace(np.nan,varWoe.woe.iloc[i])735                ))736            737            elif varWoe.interval.iloc[i].closed=='neight': #å
¨å¼738                varWoeEncode=varWoeEncode.append(pd.DataFrame(739                varData[740                    (varData[var]>varWoe.interval.iloc[i].left)&741                    (varData[var]<varWoe.interval.iloc[i].right)&742                    (~varData[var].isin(abnor))743                ].woe.replace(np.nan,varWoe.woe.iloc[i])744                ))745            else: # å
¨é746                varWoeEncode=varWoeEncode.append(pd.DataFrame(747                varData[748                    (varData[var]>=varWoe.interval.iloc[i].left)&749                    (varData[var]<=varWoe.interval.iloc[i].right)&750                    (~varData[var].isin(abnor))751                ].woe.replace(np.nan,varWoe.woe.iloc[i])752                ))753            #夿æ¯å¦ä¸ºset754        elif isinstance(varWoe.interval.iloc[i],set):755            varWoeEncode=varWoeEncode.append(pd.DataFrame(756                varData[varData[var].isin(varWoe.interval.iloc[i])].woe.replace(np.nan,varWoe.woe.iloc[i])757            ))758            #夿æ¯å¦ä¸ºlist759        elif isinstance(varWoe.interval.iloc[i],list):760            varWoeEncode=varWoeEncode.append(pd.DataFrame(761                varData[762                    (varData[var].apply(lambda x:x in varWoe.interval.iloc[i][0] and x not in abnor))763                    |(varData[var].isin(varWoe.interval.iloc[i][1]))764                ].woe.replace(np.nan,varWoe.woe.iloc[i])765            ))766        else: #为å
·ä½å¼767            varWoeEncode=varWoeEncode.append(pd.DataFrame(768                varData[varData[var]==varWoe.interval.iloc[i]].woe.replace(np.nan,varWoe.woe.iloc[i])769            ))770    varWoeEncode.sort_index(inplace=True)771    varWoeEncode.rename(columns={'woe':var},inplace=True)772    return varWoeEncode773    774def singleCharVarWoeEncoder(var,df_woe,dataSet):775    '''776    离æ£åéwoeæ å°777    @var:åéå778    @df_woe:åéåç®±åwoeå¼779    @dataSet:è¿è¡æ å°çæ°æ®780    '''781    print('-------------'+var+'-------------')782    varData=pd.DataFrame(dataSet[var])783    varData['woe']=np.nan784    785    varWoe = pd.DataFrame(df_woe[df_woe.varname==var])786    varWoe['binList']=varWoe['bingroups'].apply(787    lambda x:[i for i in str(x)[str(x).find('{')+1:str(x).find('}')].split(',')])788    print(varWoe[['bingroups','binList','woe']])789    790    varWoeEncode=pd.DataFrame()791    for i in range(len(varWoe)):792        varWoeEncode=varWoeEncode.append(pd.DataFrame(793        varData[varData[var].isin(varWoe.binList.iloc[i])].woe.replace(np.nan,varWoe.woe.iloc[i])794        ))795    varWoeEncode.sort_index(inplace=True)796    varWoeEncode.rename(columns={'woe':var},inplace=True)797    798    return varWoeEncode799def read_char_bins_for_merge(file_path,varname,df,gbflag):800    '''801    读åæä¾çåç®±è¿è¡ç¦»æ£åç®±ï¼ç¶å计ç®ivç802    @file_path:ç¹å¾å¼è·¯å¾(å个ç¹å¾çåç®±å¼)803    @varname:å个ç¹å¾åå804    @df:æ°æ®805    @gbflag:æ ç¾806    '''807    lines=pd.read_csv(file_path,header=None,sep='\n')808    lines.columns=['bingroups']809    lines['varname'] = varname810    char_count_new=charVarBinCount(lines[['varname','bingroups']],df,gbflag,varname='varname',bingroups='bingroups')811    out=cal_var_iv_ks_woe(char_count_new,varname)812    return out[0][['varname','bingroups','total_counts','good_counts','bad_counts','good_percent',813                 'bad_percent','good_cumsum','bad_cumsum','KS','WOE','IV']]814def read_num_bins_for_merge(file_path,varname,df,gbflag,abnor):815    '''816    读åæä¾çåç®±è¿è¡è¿ç»åç®±ï¼ç¶å计ç®ivç817    @file_path:ç¹å¾å¼è·¯å¾(å个ç¹å¾çåç®±å¼)818    @varname:å个ç¹å¾åå819    @df:æ°æ®820    @gbflag:æ ç¾821    @abnor:ç¹æ®å¼822    '''823    lines=pd.read_csv(file_path,header=None,sep='\n')824    lines.columns=['bingroups']825    lines['varname'] = varname826    num_count_new = numVarBinCount(lines[['varname','bingroups']],827                                  df,828                                  gbflag,829                                  abnor,830                                  varname='varname',831                                  bingroups='bingroups',832                                  transform_interval=1)833    out = cal_var_iv_ks_woe(num_count_new,varname)834    temp = out[0]835    return temp[['varname','bingroups','total_counts','good_counts','bad_counts','good_percent',836                 'bad_percent','good_cumsum','bad_cumsum','KS','WOE','IV']]837def read_num_df_for_merge(lines,varname,df,gbflag,abnor):838    '''读åæä¾çåç®±è¿è¡è¿ç»åç®±ï¼ç¶å计ç®ivç'''839    num_count_new = numVarBinCount(lines[['varname','bingroups']],840                                  df,841                                  gbflag,842                                  abnor,843                                  varname='varname',844                                  bingroups='bingroups',845                                  transform_interval=1)846    out = cal_var_iv_ks_woe(num_count_new,varname)847    temp = out[0]848    return temp['varname','bingroups','total_counts','good_counts','bad_counts','good_percent',849                 'bad_percent','good_cumsum','bad_cumsum','ks','woe','iv']850    851def cal_var_iv_ks_woe(df,varname):852    '''853    ivï¼ksï¼woe计ç®854    @df:dataframe855    @varname:åéåå表856    '''857    df[['good_percent','bad_percent']]=df[['good_counts','bad_counts']].\858    apply(lambda x: x/df[['good_counts','bad_counts']].sum(),axis=1) #计ç®å æ¯859    df[['good_cumsum','bad_cumsum']] = df[['good_percent','bad_percent']].cumsum() #计ç®ç´¯è®¡å æ¯860    861    df['KS'] = abs(df['good_cumsum']-df['bad_cumsum']) #计ç®ks862    df['WOE'] = ((df['bad_counts'].replace(0,1)/df['bad_counts'].sum())/(df['good_counts'].replace(0,1)/df['good_counts'].sum())).apply(lambda x:863    np.log(x)) #计ç®woe864    df['IV'] = ((df['bad_counts'].replace(0,1)/df['bad_counts'].sum()) - (df['good_counts'].replace(0,1)/df['good_counts'].sum())) * df['WOE'] #计ç®iv865    866    result = pd.DataFrame(df[['total_counts','good_counts','bad_counts','IV']].apply(lambda x: x.sum(),axis=0)).T867    result['KS']=np.max(df['KS'])868    result.insert(0,'varname',varname)869    return df,result870def calcChi2(df,total_col='total_counts',good_col='good_counts',bad_col='bad_counts'):871    '''塿¹å¼è®¡ç®'''872    e1 = df.iloc[0,0]*df[good_col].sum()/df[total_col].sum()873    e2 = df.iloc[0,0]*df[bad_col].sum()/df[total_col].sum()874    e3 = df.iloc[1,0]*df[good_col].sum()/df[total_col].sum()875    e4 = df.iloc[1,0]*df[bad_col].sum()/df[total_col].sum()876    if (e1!=0)&(e2!=0):877        chi2 = (df.iloc[0,1]-e1)**e1+(df.iloc[0,2]-e2)**2/e2+(df.iloc[1,1]-e3)**2/e3+(df.iloc[1,2]-e4)**2/e4878    else:879        chi2=0880    return chi2881#åå¹¶åç®±882def mergeBin(df,index1,index2):883    df.rename(index={df.index[index1]:'{},{}'.format(df.index[index1],df.index[index2]),884                    df.index[index2]:'{},{}'.format(df.index[index1],df.index[index2])},inplace=True)885    df = df.groupby(df.index,sort=False).sum()886    return df887# è¿ç»ååç®±å ç¼å·888def idNumBin(df):889    bin_id=[]890    for i in df.index:891        if i <=9:892            bin_id.append('0'+str(i)+'_'+str(df.bingroup[i]))893        else:894            bin_id.append(str(i)+'_'+str(df.bingroup[i]))895    896    df.insert(1,'bingroups',bin_id)897    return df898# 离æ£ååç»å ç¼å·899def idCharBin(df):900    bin_id=[]901    for i in df.index:902        if i<=9:903            bin_id.append('0'+str(i)+'_{'+str(df.bingroup[i])+'}')904        else:905            bin_id.append(str(i)+'_'+str(df.bingroup[i])+'}')906    df.insert(1,'bingroups',bin_id)907    return df908def get_performance(labels,probs):909    fpr, tpr,_ = metrics.roc_curve(labels,probs)910    auc_score = metrics.auc(fpr,tpr)911    w = tpr-fpr912    ks_score = w.max()913    ks_x = fpr[w.argmax()]914    ks_y = tpr[w.argmax()]915    print('AUC Score:{}'.format(metrics.roc_auc_score(labels,probs)))916    print('KS Score:{}'.format(ks_score))917    918    fig,ax = plt.subplots()919    ax.set_title('Receiver Operating Characteristic')920    plt.ylabel('True Positive Rate')      921    plt.xlabel('False Positive Rate')922    ax.plot([0,1],[0,1],'--',color=(0.6,0.6,0.6))923    ax.plot(fpr,tpr,label='AUC=%.5f'% auc_score)924    ax.plot([ks_x,ks_y],[ks_x,ks_y],'--',color='red')925    ax.text(ks_x,(ks_x+ks_y)/2,'KS=%.5f'% ks_score)926    ax.legend()927    plt.show()928def predict_score_by_codf(woe_data,gbflag,file_path='',_sep='\t'):929    '''读å忰坹woeç¼ç çæ°æ®è¿è¡é¢æµ'''930    params = get_coef(_sep, file_path=file_path)931    woe_data['intercept'] = 1932    scor = np.dot(woe_data[params.index.tolist()].values,params.values)933    934    new = pd.DataFrame({gbflag:woe_data[gbflag],935                       'scor':scor,936                       'pd':1/1(1+np.exp(-score)),937                       'score':np.around(680-scor*30/np.log(2)-np.log(60)*30/np.log(2))})...upload_website.js
Source:upload_website.js  
1/*2    SOLUTION3    You cannot just copy and paste this because4    the bucket name will need to be your bucket name5    If you run it "as is" it will not work!6    You must replaace <FMI> with your bucket name7    e.g8    qls-137408-c11c1a21378cefb1-s3bucket-1po51sid5ipg49    Keeo the quotes in there below, and literally just 10    replace the characters <FMI>11* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.12*13* Licensed under the Apache License, Version 2.0 (the "License").14* You may not use this file except in compliance with the License.15* A copy of the License is located at16*17*  http://aws.amazon.com/apache2.018*19* or in the "license" file accompanying this file. This file is distributed20* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either21* express or implied. See the License for the specific language governing22* permissions and limitations under the License.23*/24var 25    AWS = require("aws-sdk"),26    S3API = new AWS.S3({27        apiVersion: "2006-03-01",28        region: "us-east-1"29    }),30    FS = require("fs"),31    bucket_name_str = "<FMI>";32function uploadItemAsBinary(key_name_str, content_type_str, bin){33    var params = {34        Bucket: bucket_name_str,35        Key: key_name_str,36        Body: bin,37        ContentType: content_type_str,38        CacheControl: "max-age=0"39    };40    S3API.putObject(params, function(error, data){41        console.log(error, data);42    });43}44(function init(){45    var config_bin = FS.readFileSync("website/config.js");46    uploadItemAsBinary("config.js", "application/javascript", config_bin);47    var jquery_js_bin = FS.readFileSync("website/jquery-3.4.0.min.js");48    uploadItemAsBinary("jquery-3.4.0.min.js", "application/javascript", jquery_js_bin);49    var sparky_bin = FS.readFileSync("website/images/sparky.png");50    uploadItemAsBinary("sparky.png", "image/png", sparky_bin);51    var tallie_bin = FS.readFileSync("website/images/tallie.png");52    uploadItemAsBinary("tallie.png", "image/png", tallie_bin);53    var index_html_bin = FS.readFileSync("website/index.html");54    uploadItemAsBinary("index.html", "text/html", index_html_bin);55    var main_css_bin = FS.readFileSync("website/main.css");56    uploadItemAsBinary("main.css", "text/css", main_css_bin);57        58    var main_js_bin = FS.readFileSync("website/main.js");59    uploadItemAsBinary("main.js", "application/javascript", main_js_bin);60    var index_2_html_bin = FS.readFileSync("website/index2.html");61    uploadItemAsBinary("index2.html", "text/html", index_2_html_bin);62    var main_2_css_bin = FS.readFileSync("website/main2.css");63    uploadItemAsBinary("main2.css", "text/css", main_2_css_bin);64    var main_2_js_bin = FS.readFileSync("website/main2.js");65    uploadItemAsBinary("main2.js", "application/javascript", main_2_js_bin);66    var index_3_html_bin = FS.readFileSync("website/index3.html");67    uploadItemAsBinary("index3.html", "text/html", index_3_html_bin);68    var main_3_js_bin = FS.readFileSync("website/main3.js");69    uploadItemAsBinary("main3.js", "application/javascript", main_3_js_bin);70    var main_3_css_bin = FS.readFileSync("website/main3.css");71    uploadItemAsBinary("main3.css", "text/css", main_3_css_bin);72    var index_4_html_bin = FS.readFileSync("website/index4.html");73    uploadItemAsBinary("index4.html", "text/html", index_4_html_bin);74    var main_4_js_bin = FS.readFileSync("website/main4.js");75    uploadItemAsBinary("main4.js", "application/javascript", main_4_js_bin);76    var main_4_css_bin = FS.readFileSync("website/main4.css");77    uploadItemAsBinary("main4.css", "text/css", main_4_css_bin);78    var index_5_html_bin = FS.readFileSync("website/index5.html");79    uploadItemAsBinary("index5.html", "text/html", index_5_html_bin);80    var main_5_js_bin = FS.readFileSync("website/main5.js");81    uploadItemAsBinary("main5.js", "application/javascript", main_5_js_bin);82    var main_5_css_bin = FS.readFileSync("website/main5.css");83    uploadItemAsBinary("main5.css", "text/css", main_5_css_bin);84    //Mary's dragins for a future lab85    var Amaron_bin = FS.readFileSync("website/images/Amaron.png");86    uploadItemAsBinary("Amaron.png", "image/png", Amaron_bin);87    var Atlas_bin = FS.readFileSync("website/images/Atlas.png");88    uploadItemAsBinary("Atlas.png", "image/png", Atlas_bin);89    var Bahamethut_bin = FS.readFileSync("website/images/Bahamethut.png");90    uploadItemAsBinary("Bahamethut.png", "image/png", Bahamethut_bin);91    var Blackhole_bin = FS.readFileSync("website/images/Blackhole.png");92    uploadItemAsBinary("Blackhole.png", "image/png", Blackhole_bin);93    var Cassidiuma_bin = FS.readFileSync("website/images/Cassidiuma.png");94    uploadItemAsBinary("Cassidiuma.png", "image/png", Cassidiuma_bin);95    var Castral_bin = FS.readFileSync("website/images/Castral.png");96    uploadItemAsBinary("Castral.png", "image/png", Castral_bin);97    var Crimson_bin = FS.readFileSync("website/images/Crimson.png");98    uploadItemAsBinary("Crimson.png", "image/png", Crimson_bin);99    var Dexler_bin = FS.readFileSync("website/images/Dexler.png");100    uploadItemAsBinary("Dexler.png", "image/png", Dexler_bin);101    102    var Eislex_bin = FS.readFileSync("website/images/Eislex.png");103    uploadItemAsBinary("Eislex.png", "image/png", Eislex_bin);104    var Fireball_bin = FS.readFileSync("website/images/Fireball.png");105    uploadItemAsBinary("Fireball.png", "image/png", Fireball_bin);106    var Firestorm_bin = FS.readFileSync("website/images/Firestorm.png");107    uploadItemAsBinary("Firestorm.png", "image/png", Firestorm_bin);108    var Frealu_bin = FS.readFileSync("website/images/Frealu.png");109    uploadItemAsBinary("Frealu.png", "image/png", Frealu_bin);110    var Frost_bin = FS.readFileSync("website/images/Frost.png");111    uploadItemAsBinary("Frost.png", "image/png", Frost_bin);112    var Galadi_bin = FS.readFileSync("website/images/Galadi.png");113    uploadItemAsBinary("Galadi.png", "image/png", Galadi_bin);114    var Havarth_bin = FS.readFileSync("website/images/Havarth.png");115    uploadItemAsBinary("Havarth.png", "image/png", Havarth_bin);116    var Herma_bin = FS.readFileSync("website/images/Herma.png");117    uploadItemAsBinary("Herma.png", "image/png", Herma_bin);118    var Hydraysha_bin = FS.readFileSync("website/images/Hydraysha.png");119    uploadItemAsBinary("Hydraysha.png", "image/png", Hydraysha_bin);120    var Isilier_bin = FS.readFileSync("website/images/Isilier.png");121    uploadItemAsBinary("Isilier.png", "image/png", Isilier_bin);122    var Jerichombur_bin = FS.readFileSync("website/images/Jerichombur.png");123    uploadItemAsBinary("Jerichombur.png", "image/png", Jerichombur_bin);124    var Languatha_bin = FS.readFileSync("website/images/Languatha.png");125    uploadItemAsBinary("Languatha.png", "image/png", Languatha_bin);126    var Longlu_bin = FS.readFileSync("website/images/Longlu.png");127    uploadItemAsBinary("Longlu.png", "image/png", Longlu_bin);128    129    var Lucian_bin = FS.readFileSync("website/images/Lucian.png");130    uploadItemAsBinary("Lucian.png", "image/png", Lucian_bin);131    var Magnum_bin = FS.readFileSync("website/images/Magnum.png");132    uploadItemAsBinary("Magnum.png", "image/png", Magnum_bin);133    var Midnight_bin = FS.readFileSync("website/images/Midnight.png");134    uploadItemAsBinary("Midnight.png", "image/png", Midnight_bin);135    var Mino_bin = FS.readFileSync("website/images/Mino.png");136    uploadItemAsBinary("Mino.png", "image/png", Mino_bin);137    var Nightingale_bin = FS.readFileSync("website/images/Nightingale.png");138    uploadItemAsBinary("Nightingale.png", "image/png", Nightingale_bin);139    var Norslo_bin = FS.readFileSync("website/images/Norslo.png");140    uploadItemAsBinary("Norslo.png", "image/png", Norslo_bin);141    var Omnitrek_bin = FS.readFileSync("website/images/Omnitrek.png");142    uploadItemAsBinary("Omnitrek.png", "image/png", Omnitrek_bin);143    144    var Pradumo_bin = FS.readFileSync("website/images/Pradumo.png");145    uploadItemAsBinary("Pradumo.png", "image/png", Pradumo_bin);146    var Protheus_bin = FS.readFileSync("website/images/Protheus.png");147    uploadItemAsBinary("Protheus.png", "image/png", Protheus_bin);148    var Prythus_bin = FS.readFileSync("website/images/Prythus.png");149    uploadItemAsBinary("Prythus.png", "image/png", Prythus_bin);150    var Ragnorl_bin = FS.readFileSync("website/images/Ragnorl.png");151    uploadItemAsBinary("Ragnorl.png", "image/png", Ragnorl_bin);152    var Restula_bin = FS.readFileSync("website/images/Restula.png");153    uploadItemAsBinary("Restula.png", "image/png", Restula_bin);154    var Ruby_bin = FS.readFileSync("website/images/Ruby.png");155    uploadItemAsBinary("Ruby.png", "image/png", Ruby_bin);156    var Samurilio_bin = FS.readFileSync("website/images/Samurilio.png");157    uploadItemAsBinary("Samurilio.png", "image/png", Samurilio_bin);158    var Shadow_bin = FS.readFileSync("website/images/Shadow.png");159    uploadItemAsBinary("Shadow.png", "image/png", Shadow_bin);160    var Sheblonguh_bin = FS.readFileSync("website/images/Sheblonguh.png");161    uploadItemAsBinary("Sheblonguh.png", "image/png", Sheblonguh_bin);162    var Shulmi_bin = FS.readFileSync("website/images/Shulmi.png");163    uploadItemAsBinary("Shulmi.png", "image/png", Shulmi_bin);164    165    var Smolder_bin = FS.readFileSync("website/images/Smolder.png");166    uploadItemAsBinary("Smolder.png", "image/png", Smolder_bin);167    var Sonic_bin = FS.readFileSync("website/images/Sonic.png");168    uploadItemAsBinary("Sonic.png", "image/png", Sonic_bin);169    var Sprinkles_bin = FS.readFileSync("website/images/Sprinkles.png");170    uploadItemAsBinary("Sprinkles.png", "image/png", Sprinkles_bin);171    var Sukola_bin = FS.readFileSync("website/images/Sukola.png");172    uploadItemAsBinary("Sukola.png", "image/png", Sukola_bin);173    174    var Tagnaurak_bin = FS.readFileSync("website/images/Tagnaurak.png");175    uploadItemAsBinary("Tagnaurak.png", "image/png", Tagnaurak_bin);176    var Tornado_bin = FS.readFileSync("website/images/Tornado.png");177    uploadItemAsBinary("Tornado.png", "image/png", Tornado_bin);178    var Treklor_bin = FS.readFileSync("website/images/Treklor.png");179    uploadItemAsBinary("Treklor.png", "image/png", Treklor_bin);180    var Warcumer_bin = FS.readFileSync("website/images/Warcumer.png");181    uploadItemAsBinary("Warcumer.png", "image/png", Warcumer_bin);182    var Xanya_bin = FS.readFileSync("website/images/Xanya.png");183    uploadItemAsBinary("Xanya.png", "image/png", Xanya_bin);184    var Yuxo_bin = FS.readFileSync("website/images/Yuxo.png");185    uploadItemAsBinary("Yuxo.png", "image/png", Yuxo_bin);...gen_appbin.py
Source:gen_appbin.py  
...54		fp.write(data)55		fp.close()56	else:57		print '%s write fail\n'%(file_name)58def combine_bin(file_name,dest_file_name,start_offset_addr,need_chk):59    global chk_sum60    global blocks61    if dest_file_name is None:62        print 'dest_file_name cannot be none\n'63        sys.exit(0)64    if file_name:65        fp = open(file_name,'rb')66        if fp:67        	########## write text ##########68            fp.seek(0,os.SEEK_END)69            data_len = fp.tell()70            if data_len:71		if need_chk:72                    tmp_len = (data_len + 3) & (~3)73		else:74	            tmp_len = (data_len + 15) & (~15)75                data_bin = struct.pack('<II',start_offset_addr,tmp_len)76                write_file(dest_file_name,data_bin)77                fp.seek(0,os.SEEK_SET)78                data_bin = fp.read(data_len)79                write_file(dest_file_name,data_bin)80		if need_chk:81		    for loop in range(len(data_bin)):82		        chk_sum ^= ord(data_bin[loop])83                # print '%s size is %d(0x%x),align 4 bytes,\nultimate size is %d(0x%x)'%(file_name,data_len,data_len,tmp_len,tmp_len)84                tmp_len = tmp_len - data_len85                if tmp_len:86                    data_str = ['00']*(tmp_len)87                    data_bin = binascii.a2b_hex(''.join(data_str))88                    write_file(dest_file_name,data_bin)89		    if need_chk:90			for loop in range(len(data_bin)):91			    chk_sum ^= ord(data_bin[loop])92                blocks = blocks + 193        	fp.close()94        else:95        	print '!!!Open %s fail!!!'%(file_name)96def getFileCRC(_path): 97    try: 98        blocksize = 1024 * 64 99        f = open(_path,"rb") 100        str = f.read(blocksize) 101        crc = 0 102        while(len(str) != 0): 103            crc = binascii.crc32(str, crc) 104            str = f.read(blocksize) 105        f.close() 106    except: 107        print 'get file crc error!' 108        return 0 109    return crc110def gen_appbin():111    global chk_sum112    global crc_sum113    global blocks114    if len(sys.argv) != 7:115        print 'Usage: gen_appbin.py eagle.app.out boot_mode flash_mode flash_clk_div flash_size_map'116        sys.exit(0)117    elf_file = sys.argv[1]118    boot_mode = sys.argv[2]119    flash_mode = sys.argv[3]120    flash_clk_div = sys.argv[4]121    flash_size_map = sys.argv[5]122    user_bin = sys.argv[6]123    flash_data_line  = 16124    data_line_bits = 0xf125    irom0text_bin_name = 'eagle.app.v6.irom0text.bin'126    text_bin_name = 'eagle.app.v6.text.bin'127    data_bin_name = 'eagle.app.v6.data.bin'128    rodata_bin_name = 'eagle.app.v6.rodata.bin'129    flash_bin_name ='eagle.app.flash.bin'130    BIN_MAGIC_FLASH  = 0xE9131    BIN_MAGIC_IROM   = 0xEA132    data_str = ''133    sum_size = 0134    if os.getenv('COMPILE')=='gcc' :135        cmd = 'xtensa-lx106-elf-nm -g ' + elf_file + ' > eagle.app.sym'136    else :137        cmd = 'xt-nm -g ' + elf_file + ' > eagle.app.sym'138    os.system(cmd)139    fp = file('./eagle.app.sym')140    if fp is None:141        print "open sym file error\n"142        sys.exit(0)143    lines = fp.readlines()144    fp.close()145    entry_addr = None146    p = re.compile('(\w*)(\sT\s)(call_user_start)$')147    for line in lines:148        m = p.search(line)149        if m != None:150            entry_addr = m.group(1)151            # print entry_addr152    if entry_addr is None:153        print 'no entry point!!'154        sys.exit(0)155    data_start_addr = '0'156    p = re.compile('(\w*)(\sA\s)(_data_start)$')157    for line in lines:158        m = p.search(line)159        if m != None:160            data_start_addr = m.group(1)161            # print data_start_addr162    rodata_start_addr = '0'163    p = re.compile('(\w*)(\sA\s)(_rodata_start)$')164    for line in lines:165        m = p.search(line)166        if m != None:167            rodata_start_addr = m.group(1)168            # print rodata_start_addr169    # write flash bin header170    #============================171    #  SPI FLASH PARAMS172    #-------------------173    #flash_mode=174    #     0: QIO175    #     1: QOUT176    #     2: DIO177    #     3: DOUT178    #-------------------179    #flash_clk_div=180    #     0 :  80m / 2181    #     1 :  80m / 3182    #     2 :  80m / 4183    #    0xf:  80m / 1184    #-------------------185    #flash_size_map=186    #     0 : 512 KB (256 KB + 256 KB)187    #     1 : 256 KB188    #     2 : 1024 KB (512 KB + 512 KB)189    #     3 : 2048 KB (512 KB + 512 KB)190    #     4 : 4096 KB (512 KB + 512 KB)191    #     5 : 2048 KB (1024 KB + 1024 KB)192    #     6 : 4096 KB (1024 KB + 1024 KB)193    #-------------------194    #   END OF SPI FLASH PARAMS195    #============================196    byte2=int(flash_mode)&0xff197    byte3=(((int(flash_size_map)<<4)| int(flash_clk_div))&0xff)198    app=int(user_bin)&0xff199    if boot_mode == '2':200        # write irom bin head201        #data_bin = struct.pack('<BBBBI',BIN_MAGIC_IROM,4,byte2,byte3,long(entry_addr,16))202        data_bin = struct.pack('<BBBBI',BIN_MAGIC_IROM,4,0,app,long(entry_addr,16))203        sum_size = len(data_bin)204        write_file(flash_bin_name,data_bin)205        206        # irom0.text.bin207        combine_bin(irom0text_bin_name,flash_bin_name,0x0,0)208    if boot_mode == '1':209         data_bin = struct.pack('<BBBBI',BIN_MAGIC_FLASH,3,0,app,long(entry_addr,16))210    else:211         data_bin = struct.pack('<BBBBI',BIN_MAGIC_FLASH,3,byte2,byte3,long(entry_addr,16))212    sum_size = len(data_bin)213    write_file(flash_bin_name,data_bin)214    # text.bin215    combine_bin(text_bin_name,flash_bin_name,TEXT_ADDRESS,1)216    # data.bin217    if data_start_addr:218        combine_bin(data_bin_name,flash_bin_name,long(data_start_addr,16),1)219    # rodata.bin220    combine_bin(rodata_bin_name,flash_bin_name,long(rodata_start_addr,16),1)221    # write checksum header222    sum_size = os.path.getsize(flash_bin_name) + 1223    sum_size = flash_data_line - (data_line_bits&sum_size)224    if sum_size:225        data_str = ['00']*(sum_size)226        data_bin = binascii.a2b_hex(''.join(data_str))227        write_file(flash_bin_name,data_bin)228    write_file(flash_bin_name,chr(chk_sum & 0xFF))229    	230    if boot_mode == '1':231        sum_size = os.path.getsize(flash_bin_name)232        data_str = ['FF']*(0x10000-sum_size)233        data_bin = binascii.a2b_hex(''.join(data_str))234        write_file(flash_bin_name,data_bin)235        fp = open(irom0text_bin_name,'rb')236        if fp:237            data_bin = fp.read()238            write_file(flash_bin_name,data_bin)239            fp.close()240        else :241            print '!!!Open %s fail!!!'%(flash_bin_name)242            sys.exit(0)243    if boot_mode == '1' or boot_mode == '2':244        all_bin_crc = getFileCRC(flash_bin_name)245        print all_bin_crc246        if all_bin_crc < 0:247            all_bin_crc = abs(all_bin_crc) - 1248        else :249            all_bin_crc = abs(all_bin_crc) + 1250        print all_bin_crc251        write_file(flash_bin_name,chr((all_bin_crc & 0x000000FF))+chr((all_bin_crc & 0x0000FF00) >> 8)+chr((all_bin_crc & 0x00FF0000) >> 16)+chr((all_bin_crc & 0xFF000000) >> 24))252    cmd = 'rm eagle.app.sym'253    os.system(cmd)254if __name__=='__main__':...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
