Crypto library in JS

PinBlock in JS

Implementation of PinBlock Format 0 based on ISO-9564 standard. The PIN block is constructed by XOR-ing two 64-bit fields: the plain text PIN field and the account number field, both of which comprise 16 four-bit nibbles.

The plain text PIN field is :

The account number field is:

Extended PIN blocks

Formats 0 to 3 are all suitable for use with the Triple Data Encryption Algorithm, as they correspond to its 64-bit block size. However the standard allows for other encryption algorithms with larger block sizes, e.g. the Advanced Encryption Standard has a block size of 128 bits. In such cases the PIN must be encoding into an extended PIN block, the format of which is defined in a 2015 amendment to ISO 9564-1. In this library, we have used 3DES in ECB/NoPadding mode.

For better clarification please refer to the following online tool: https://neapay.com/online-tools/calculate-pin-block.html

Build

npm install

Run unit tests

./node_modules/mocha/bin/mocha -r esm