You're talking about encryption but clearly need a hashing function. You can then relate the hash to any data model you want (whatever it is you want to 'encrypt' in this case) in a database. The hash is used like the key of a key-value store and can be completely random. The final size of an encryted string is always directly related to the size of the original string. Otherwise you're probably confusing hashes and encryption.
So a simple use-case:
- A user registers into a website.
- The registration controller creates a new record into the 'pending_users' table which has only 2 columns: user_id and random_key.
- And email is sent to the user containing the value of the random_key which is exposed as a link to verification.php?key=$random_key
When the user executes the verification.php controller, the controller checks for the presence of the $random_key in the pending_users table. If found, it removes the record and changes a flag in the users table (active_account = true for example). If not found an error is sent back to the user.
Hope this helps,
Cheers