1. Go to this page and download the library: Download he426100/hyperf-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/ */
he426100 / hyperf-encryption example snippets
declare(strict_types=1);
namespace App\Http\Controller;
use Hyperf\HttpServer\Request;
use HyperfExt\Encryption\Crypt;
class UpdatePasswordController
{
public function update(Request $request)
{
// ……
$user->fill([
'secret' => Crypt::encrypt($request->input('secret'))
])->save();
}
}
use HyperfExt\Encryption\Crypt;
$encrypted = Crypt::encrypt('Hello world.', false);
$decrypted = Crypt::decrypt($encrypted);
use HyperfExt\Encryption\Crypt;
use HyperfExt\Encryption\Exception\DecryptException;
try {
$decrypted = Crypt::decrypt($encryptedValue);
} catch (DecryptException $e) {
//
}