laravel用指定key加密解密

2020-09-27 10:54:48 阅读:4 编辑
   $key = "aa2vNqhhBcXtJoBB";
    $key = \Illuminate\Support\Str::random(16);
    print_r($key."\n");
    $e = new \Illuminate\Encryption\Encrypter($key);
    $encrypted = $e->encryptString('Hello world.');
    print_r($encrypted."\n");
    $decrypted = $e->decryptString($encrypted);
    print_r($decrypted."\n");