ParagonIE\Halite\KeyFactory::loadEncryptionKeyPair PHP Method

loadEncryptionKeyPair() public static method

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

Usage Example

示例#1
0
 public function testFileStorage()
 {
     $filename = \tempnam(__DIR__ . '/tmp/', 'key');
     $key = KeyFactory::generateEncryptionKeyPair();
     KeyFactory::save($key, $filename);
     $copy = KeyFactory::loadEncryptionKeyPair($filename);
     $this->assertEquals($key->getPublicKey()->getRawKeyMaterial(), $copy->getPublicKey()->getRawKeyMaterial());
     \unlink($filename);
 }
All Usage Examples Of ParagonIE\Halite\KeyFactory::loadEncryptionKeyPair