Limit Laravel 5 Encryption Length

I have a Laravel5 web application business directory.

When I encrypt the value as

$cryptval = Crypt::encrypt(1);

result  =  eyJpdiI6IndhaFZFNlhIRDlURzdXanJVMEhBM0E9PSIsInZhbHVlIjoidWF3VzRFZDhyRHltUlwveDdyV0VVWnc9PSIsIm1hYyI6IjE5YjA2YWIyN2Q0MTBlYjdhNDJiNDE5ZjY2OGQ2MDA2NzQ3ZTA4ODc4NzY0ZTIwMjBiMzQxN2RjNmM5ZDg3ZjYifQ==

this gives a long string of about 250 lengths.

Is there a way to limit the length of this string in laravel?

My client should add an URL with an encrypted value to the mail function. eg:

www.example.com/varify/eyJpdiI6IndhaFZFNlhIRDlURzdXanJVMEhBM0E9PSIsInZhbHVlIjoidWF3VzRFZDhyRHltUlwveDdyV0VVWnc9PSIsIm1hYyI6IjE5YjA2YWIyN2Q0MTBlYjdhNDJiNDE5ZjY2OGQ2MDA2NzQ3ZTA4ODc4NzY0ZTIwMjBiMzQxN2RjNmM5ZDg3ZjYifQ==

But the mail function only allows some URL length :(

+5
source share
2 answers

- , -.

| id | hash             | timestamp | random_key |
| 1  | some-hash        | 125346164 | 21415      |
| 2  | some-other-hash  | 123513515 | 25151      |

, :

www.example.com/verify/some-hash

:

www.example.com/verify/1

id , , random_key.

$id = 1;
$timestamp = 125346164;
$randomKey = 21415;

$key = base64_encode($timestamp . $randomKey . $id);

echo 'http://www.domain.com/verify/' . $key;

// http://www.domain.com/verify/MTI1MzQ2MTY0MjE0MTUx

, , , , , URL- 2000 . , , 32 , .

: uuid, , , , , , d3d29d70-1d25-11e3-8591-034165a3a613.

+2

. "" . md5 ( ($model-> id))

md5 , Laravel, .

0

Source: https://habr.com/ru/post/1612212/


All Articles