How to use bin method in autotest

Best Python code snippet using autotest_python

tlv_analyzer.js

Source:tlv_analyzer.js Github

copy

Full Screen

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 ...

Full Screen

Full Screen

calcVarIndex.py

Source:calcVarIndex.py Github

copy

Full Screen

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))})...

Full Screen

Full Screen

upload_website.js

Source:upload_website.js Github

copy

Full Screen

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);...

Full Screen

Full Screen

gen_appbin.py

Source:gen_appbin.py Github

copy

Full Screen

...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__':...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful