ParagonIE\Halite\KeyFactory::loadEncryptionSecretKey PHP Method

loadEncryptionSecretKey() public static method

Load, specifically, an encryption public key from a file
public static loadEncryptionSecretKey ( string $filePath ) : EncryptionSecretKey
$filePath string
return EncryptionSecretKey
    public static function loadEncryptionSecretKey(string $filePath) : EncryptionSecretKey
    {
        if (!\is_readable($filePath)) {
            throw new Alerts\CannotPerformOperation('Cannot read keyfile: ' . $filePath);
        }
        return new EncryptionSecretKey(self::loadKeyFile($filePath));
    }

Usage Example

Example #1
0
 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);
                 break;
             case 'SignatureKeyPair':
                 $keys[$index] = KeyFactory::loadSignatureKeyPair($path);
                 break;
             default:
                 throw new \Error(\trk('errors.crypto.unknown_key_type', $keyConfig['type']));