The CVV2 is a 3- or 4-digit value printed on the card or signature strip, but not encoded on the magnetic stripe.
MasterCard, Visa and Discover
credit and debit cards have a 3-digit code, called the "CVC2" (card validation code), "CVV2" (card verification value), and "CID" (card identification number), respectively. It is not embossed like the card number, and is always the final group of numbers printed on the back signature panel of the card. New North American MasterCard and Visa cards feature the "CVC2" in a separate panel to the right of the signature strip. This has been done to prevent overwriting of the numbers by signing the card.
cards have a 4-digit code printed on the front side of the card above the number, referred to as the CID. It is printed flat, not embossed like the card number.
The number is generated when the card is issued, by encrypting the card number and expiration date under a key known only to the issuing bank.