What encryption scheme returns a short string? I want a small result less than 32 characters. I also want to be able to decrypt it back to the original plaintext. The purpose is email verification, where the code is sent by email. When the code is received the user logs in into the site and enters the code (or clicks on the link).
EDIT: DECRYPTION is important as after verification i need to relate two non related records
Thanks
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:
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