It can generally be seen in the last three digits of a series of signature columns on the back of bank cards. The UnionPay standard card organized by UnionPay is called CVN2, MasterCard is called CVC2, VISA is called CVV2, and AE American Express is called CSC2. These three-digit security codes are generated by a special encryption algorithm according to your account number, ID card, name and other information.
Calculation steps of CVN value:
Two 64-bit authentication keys named KeyA and KeyB are used to calculate CVN.
1) The data sources for calculating CVN include: main account number (PAN), card validity period (YYMM) and service code, which are arranged from left to right;
2) Expand the above data source into binary data with 128 bits, and if it is less than 128 bits, add 0 to the right;
3) Divide the binary data of 128 bits into two 64-bit data blocks, with the leftmost 64 bits being Block 1 and the rightmost 64 bits being Block 2;;
4) encrypt block1with KeyA;
5) XOR the encrypted result of Block 1 with Block2, and encrypt the XOR result with KeyA;
6) Decrypt the encryption result of the last step with KeyB;
7) Encrypt the decryption result of the previous step with KeyA;
8) extracting numbers (0-9) from left to right to form a group of numbers;
9) Extract the characters (A-F) in the encryption result from left to right, subtract 10, and make the remainder into a set of numbers, which are arranged after the numbers in step 8.
10) The first set of three digits on the left of step 9 is the CVN value.
References:
Baidu Encyclopedia: Bank Card Security Code