How to easy encode and “compress” URL/e-mail adress to string in PHP?
String should be:
- difficult to decode by user
- as short as possible (compressed)
- similar URLs should be different
after encoding - not in database
- easy to decode/uncompress by PHP script
ex. input -> output,
stackoverflow.com/1/ -> “n3uu399”,
stackoverflow.com/2/ -> “ojfiejfe8”
Not very short but you could zip it with a password and encode it using base64. Note that zip is not too safe when it comes to passwords, but should be ok if your encrypted value is intended to have a short lifetime.
Note that whatever you do, you won’t be able to generate a somewhat safe encoding unless you agree to store some unaccessible information locally. This means, whatever you do, take it as given that anyone can access the pseudo-encrypted data with enough time, be it by reverse engineering your algorithm, brute-forcing your passwords or whatever else is necessary.