How to calculate PIN Block
We will use ISO ANSI/ISO-0 pinblock format for this example.
Here are the steps:
1. Use a 6-digit PIN, for example: 123456
2. Create the first part of the PIN block:
* Add the PIN length with leading zero => 06
* Add the PIN itself => 123456
* Add the letter F to a total of 16 characters
Example:
06 + 123456 + FFFFFFFF = 06123456FFFFFFFF
3. Create the second part of the PIN block from the card number (PAN):
* Take the card number without the first 3 digits and without
the last digit for a total of 12 digits
* Add four zeros (0000) in front of it.
Example:
Card number = 4451234567890129
Take the middle 12 digits = 123456789012
Then the 2nd block = 0000123456789012
4. Perform XOR HEX between the two blocks
XOR(06123456FFFFFFFF, 0000123456789012) = 06122662A9876FED
5. Encrypt the XOR result with the key using the 3DES algorithm.
Example:
Key = E8DD93B8AF13999C7644C0FE11F5D2A7
Pinblock = 3DES(06122662A9876FED, E8DD93B8AF13999C7644C0FE11F5D2A7)
Pinblock = ABC5E23474210DAC