1

When I apply Crypt::encrypt(1) I'm getting this encrypted string:

eyJpdiI6IlBoQnliQkZkb0NPT1g5NG9FbkpqV2hLa3ZLUnlWSEFRMEZwM2YxTEdNVk09IiwidmFsdWUiOiJ0N0kyWmZvRWVETzE3WTJWVU5DS1ZpTVFYTGpXNHQxT2YyQWdsMFgxK0xvPSIsIm1hYyI6IjAzMjAzNzdhNzZmYmZiZDVkZGJkMjM5MWY5NjhkNzJjMWFhMzNiYmYyZDJkODNlMmFkODcyNzdhYTE3ZjFkODMifQ==

Is it possible to make string shorter (4-5 times shorter) in Laravel, using the same two-way encryption?

Sergey Tsibel
  • 1,595
  • 1
  • 18
  • 31
  • What do you mean? By performing two way encryption on the original string? What do you want to achieve? – Maarten Bodewes Mar 31 '14 at 20:06
  • I would like to get some short random string like 1asdf13, which will be different every time after I call Crypt::encrypt(1). By using two-way encryption I meant that the way we encode/decode things should be the same. – Sergey Tsibel Mar 31 '14 at 20:31
  • I don't know laravel, but I guess you want the same thing as [this question](http://stackoverflow.com/questions/22744134/how-do-you-encrypt-an-integer-to-a-string-of-five-characters#comment34669909_22744134). That question is marked a duplicate as well, but it can be tricky to find earlier questions if you don't know exactly what you're looking for. – Maarten Bodewes Apr 01 '14 at 07:19

1 Answers1

4

What you want to do, instead of encrypting uri portion is obfuscate it. For example, one of the great libraries for php is Hashids

Sergey Tsibel
  • 1,595
  • 1
  • 18
  • 31