-
-
Notifications
You must be signed in to change notification settings - Fork 1
Crypto
StefansArya edited this page Apr 18, 2019
·
3 revisions
You may need to import this feature on top of your code.
use \Scarlets\Library\Crypto;
The security configuration are stored on /config/security.php
.
The default cipher will be used if the cipher parameter was false.
This library is using openssl
php extension.
So make sure you have enabled it before use.
And the available cipher are listed on php documentation.
Crypto::encrypt($text, $pass=false, $cipher=false, $mask=false);
Set the mask parameter to true if you want to encode any symbol
to text. Make sure you have change default crypto_mask
on the configuration to improve security.
$data = Crypto::encrypt('hello', 'secretcode');
// Output:
// Tst2nVwwwSPiTp+Olh4QTRdKbHc9PQ==
Crypto::decrypt($encryptedText, $pass=false, $cipher=false, $mask=false);
$data = Crypto::decrypt('Tst2nVwwwSPiTp+Olh4QTRdKbHc9PQ==', 'secretcode');
// Output:
// hello