ANSI X9.8 calculates PinBlock

zhaozj2021-02-16  82

PIN format ANSI X9.8 FORMAT (with the main account information) PIN Block format is equal to PIN bit bit or protocol: PIN format: Byte 1 PIN Length byte 2 - Byte 3/4/5/6/7 4 - 12 PIN (4 bits per pin) byte 4/5/6/7/8 - Byte 8 Filler "f" (each "F" 4 bit) primary account format: Byte 1 - Byte 2 0x0000Byte 3 - byte 8 12 main account 12-digit primary account tissue: Take the right 12 bits of the host account (excluding the rightmost check digits), less than 12 digits left "0x00".

For example: 明文 PIN 123456, set: The account number on the magnetic card is: 123456789012345678 Intercept account number: 678901234567 Used for the primary account for PIN encryption: 0x00 0x00 0x67 0x89 0x01 0x23 0x45 0x67 Pin Block is 0x06 0x12 0x34 0x56 0xFF 0xFF 0xFF 0xFF different or 0x00 0x00 0x67 0x89 0x01 0x23 0x45 0x67 result is 0x06 0x12 0x53 0xDF 0xFE 0xDC 0xBA 0x98

Design: The primary account number on the magnetic card is: 1234567890123456 Intercept account number: 456789012345 The primary account for PIN encryption is: 0x00 0x00 0x45 0x67 0x89 0x01 0x23 0x45 Pin Block is 0x06 0x12 0x34 0x56 0xFF 0xFF 0xFF 0xFF 0x00 0x00 0x45 0x67 0x89 0x01 0x23 0x45 results are 0x06 0x12 0x71 0x31 0x76 0xfE 0xDC 0XBA? PIN Encrypted Decryptive Provincial Center (Peripheral System) Before sending messages to the National Center (Provincial Center), apply the PIK encryption to PIN encryption Go to the National Center (Provincial Center).

/ ** * getpinblock * Standard ANSI X9.8 Format Pin Block Calculation * Pin Block format is equal to PIN bit bit or primary account; * @Param Pin string * @Param Accno string * @return Byte [ ] * / Private byte [] process (string pin, string accno) {byte arraccno [] = gethaccno; Byte Arrpin [] = gethpin (pin); Byte Arrret [] = new byte [8]; // Pin Block format is equal to PIN bit bit or primary account; for (int i = 0; i <8; i ) {Arrret [i] = (byte) (arrpin [i] ^ arraccno [i]);} util.printhexstring "Pinblock:", Arrret; Return Arrret;

/ ** * gethpin * Convert the password * PIN format * Byte 1 pin length * Byte 2 - Byte 3/4/5/6/7 4 - PIN (4 bits per pin) * Byte 4/5/6/7/8 - Byte 8 Filler "F" (each "F" 4 bits * @Param Pin String * @return Byte [] * / private byte [] gethpin (String Pin) { Byte arrpin [] = pin.getbytes (); byte encode [] = new byte [8]; eNCode [0] = (byte) 0x06; Encode [1] = (byte) Util.unitebytes (Arrpin [0], arrpin [1]); Encode [2] = (byte) Util.uniteBytes (Arrpin [2], Arrpin [3]); Encode [3] = (byte) Util.Unitebytes (Arrpin [4], Arrpin [5]) ENCODE [4] = (byte) 0xff; Encode [5] = (byte) 0xff; Encode [6] = (byte) 0xff; Encode [7] = (Byte) 0xff; util.printhexstring ("Encode PIN:" , ENCODE; RETURN ENCODE;

转载请注明原文地址:https://www.9cbs.com/read-14614.html

New Post(0)