ParagonIE\Halite\KeyFactory::loadAuthenticationKey PHP Method

loadAuthenticationKey() public static method

Load a symmetric authentication key from a file
public static loadAuthenticationKey ( string $filePath ) : AuthenticationKey
$filePath string
return AuthenticationKey
    public static function loadAuthenticationKey(string $filePath) : AuthenticationKey
    {
        if (!\is_readable($filePath)) {
            throw new Alerts\CannotPerformOperation('Cannot read keyfile: ' . $filePath);
        }
        return new AuthenticationKey(self::loadKeyFile($filePath));
    }

Usage Example

Example #1
0
     \mkdir(ROOT . '/config/keyring/', 0750);
 }
 $keyRing = \Airship\loadJSON(ROOT . '/config/keyring.json');
 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);