ParagonIE\Halite\KeyFactory::generateEncryptionKey PHP Method

generateEncryptionKey() public static method

Generate an an encryption key (symmetric-key cryptography)
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));
    }

Usage Example

コード例 #1
0
 /**
  * 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.");
 }
All Usage Examples Of ParagonIE\Halite\KeyFactory::generateEncryptionKey