Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel difference between crypt::encrypt and crypt::encryptString

Tags:

laravel

crypt

I am still new on laravel, and just use laravel package name Crypt

but I found some that there are

Crypt::encrypt

and

Crypt::encryptString

what is the difference between them?

like image 258
Steven Y. Avatar asked Sep 11 '26 19:09

Steven Y.


1 Answers

You can always refer to source code to know.

See Line 122 of Encrypter.php:

    return $this->encrypt($value, false);

Behind the scenes the encryptString calls the encrypt() method with false as second parameter, meaning that it won't serialize the value you give.

There's no difference in the behavior, but it will encrypt faster and the result will be slightly smaller because it won't contain string serialization.

like image 173
Elias Soares Avatar answered Sep 13 '26 21:09

Elias Soares



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!