You should use some mathematical way to validate the license codes to verify that the codes are correct. For example, one very simple way would be to use 20 digit key, with the last 10 digits being in reverse order of the first 10 digits.
But you probably want to use something more strong like cryptographic algorithms such as RSA. You can consider using 3rd part license management like
CryptoLicensing.