loadEncryptionKey() 공개 정적인 메소드

Load a symmetric encryption key from a file
public static loadEncryptionKey ( string $filePath ) : EncryptionKey
$filePath string
리턴 EncryptionKey
예제 #1
0
 /**
  * SecureJwt constructor.
  *
  * @param string $keyFile
  */
 public function __construct($keyFile = '')
 {
     $this->key = KeyFactory::loadEncryptionKey($keyFile);
 }
예제 #2
0
 /**
  * Perform decryption
  *
  * @param $text
  * @return mixed
  */
 public static function decrypt($text)
 {
     $key = KeyFactory::loadEncryptionKey(config('laracrypt.path'));
     return Crypto::decrypt($text, $key);
 }
예제 #3
0
파일: keys.php 프로젝트: paragonie/airship
 if (empty($keyRing)) {
     // This is critical to Airship's functioning.
     throw new \Error(\trk('errors.crypto.keyring_missing'));
 }
 $state = \Airship\Engine\State::instance();
 $keys = [];
 foreach ($keyRing as $index => $keyConfig) {
     $path = ROOT . '/config/keyring/' . $keyConfig['file'];
     if (\file_exists($path)) {
         // Load it from disk
         switch ($keyConfig['type']) {
             case 'AuthenticationKey':
                 $keys[$index] = KeyFactory::loadAuthenticationKey($path);
                 break;
             case 'EncryptionKey':
                 $keys[$index] = KeyFactory::loadEncryptionKey($path);
                 break;
             case 'EncryptionPublicKey':
                 $keys[$index] = KeyFactory::loadEncryptionPublicKey($path);
                 break;
             case 'EncryptionSecretKey':
                 $keys[$index] = KeyFactory::loadEncryptionSecretKey($path);
                 break;
             case 'SignaturePublicKey':
                 $keys[$index] = KeyFactory::loadSignaturePublicKey($path);
                 break;
             case 'SignatureSecretKey':
                 $keys[$index] = KeyFactory::loadSignatureSecretKey($path);
                 break;
             case 'EncryptionKeyPair':
                 $keys[$index] = KeyFactory::loadEncryptionKeyPair($path);
예제 #4
0
<?php

declare (strict_types=1);
use ParagonIE\Halite\HiddenString;
use ParagonIE\Halite\Password;
use ParagonIE\Halite\KeyFactory;
// First, manage the keys
if (!\file_exists('01-secret-key.txt')) {
    $secretKey = KeyFactory::generateEncryptionKey();
    KeyFactory::save($secretKey, '01-secret-key.txt');
} else {
    $secretKey = KeyFactory::loadEncryptionKey('01-secret-key.txt');
}
$password = new HiddenString('correct horse battery staple');
$hash = Password::hash($password, $secretKey);
if (Password::verify($password, $hash, $secretKey)) {
    echo 'Access granted', "\n";
} else {
    echo 'Access DENIED!', "\n";
    exit(255);
}