1. Go to this page and download the library: Download hyperf-ljh/encryption library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hyperf-ljh / encryption example snippets
declare(strict_types=1);
namespace App\Http\Controller;
use Hyperf\HttpServer\Request;
use HyperfLjh\Encryption\Crypt;
class UpdatePasswordController
{
public function update(Request $request)
{
// ……
$user->fill([
'secret' => Crypt::encrypt($request->input('secret'))
])->save();
}
}
use HyperfLjh\Encryption\Crypt;
$encrypted = Crypt::encrypt('Hello world.', false);
$decrypted = Crypt::decrypt($encrypted);
use HyperfLjh\Encryption\Crypt;
use HyperfLjh\Encryption\Exception\DecryptException;
try {
$decrypted = Crypt::decrypt($encryptedValue);
} catch (DecryptException $e) {
//
}