public static generateEncryptionKey ( string &$secretKey = '' ) : EncryptionKey | ||
$secretKey | string | |
return | EncryptionKey |
public static function generateEncryptionKey(string &$secretKey = '') : EncryptionKey
{
$secretKey = \Sodium\randombytes_buf(\Sodium\CRYPTO_STREAM_KEYBYTES);
return new EncryptionKey(new HiddenString($secretKey));
}
/** * Execute the console command. * * @return mixed */ public function handle() { $enc_key = KeyFactory::generateEncryptionKey(); try { KeyFactory::save($enc_key, config('laracrypt.path')); } catch (\Throwable $t) { $this->error($t); } return $this->info("Your LaraCrypt encryption key has been generated."); }