ParagonIE\Halite\KeyFactory::generateEncryptionKey PHP 메소드

generateEncryptionKey() 공개 정적인 메소드

Generate an an encryption key (symmetric-key cryptography)
public static generateEncryptionKey ( string &$secretKey = '' ) : EncryptionKey
$secretKey string
리턴 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