public static loadEncryptionKeyPair ( string $filePath ) : |
||
$filePath | string | |
return |
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)));
}
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); }