0

I would like to be able to encrypt (and by encrypt it has no means to be secure, so maybe obscure is the better word) a number so that the number to the naked eye has no relevance. The number is essentially going to be a lobby number so will look like

http://test.com/lobby/1035

I'm using PHP so if there is a way the url could look like

http://test.com/lobby/g4fg1

but when decrypted still go to lobby 1035. I'm probably missing a trick but any help would be appreciated! Thanks

Ryan Kennedy
  • 114
  • 7
  • 1
    What are you trying to protect against? – Rowland Shaw Aug 17 '15 at 16:18
  • That's the thing with encrypting something. When you decrypt it, it is supposed to return the original value. Maybe you're looking for hashing the value, instead. – al'ein Aug 17 '15 at 16:25
  • 1
    This might help http://stackoverflow.com/questions/9262109/php-simplest-two-way-encryption Basically you could use any two way encryption. But I wonder why you'd want to encrypt this value to begin with. – Squeegy Aug 17 '15 at 16:28
  • It would be just to hide it from the user, but to also make it bookmark-able, Scott has the perfect solution, thanks thought! – Ryan Kennedy Aug 18 '15 at 11:22

3 Answers3

4

Instead of encrypting a URL (which is foolhardy), why not add a separate field to the database table for the lobbies that contains a unique, short, randomly generated token and reference it based on that?

Scott Arciszewski
  • 33,610
  • 16
  • 89
  • 206
0

http://hashids.org/php/ has a good implementation for this.

mcq8
  • 249
  • 1
  • 5
-1

You could convert every character to ASCII, shift it (number could be generated from the salt), convert it back. Then you would get kind of simply hashed input.

Function for that are ord and chr.

m_pro_m
  • 340
  • 4
  • 11