Neos\Flow\Security\Cryptography\RsaWalletServicePhp::encryptWithPublicKey PHP Метод

encryptWithPublicKey() публичный Метод

Encrypts the given plaintext with the public key identified by the given fingerprint
public encryptWithPublicKey ( string $plaintext, string $fingerprint ) : string
$plaintext string The plaintext to encrypt
$fingerprint string The fingerprint to identify to correct public key
Результат string The ciphertext
    public function encryptWithPublicKey($plaintext, $fingerprint)
    {
        $cipher = '';
        openssl_public_encrypt($plaintext, $cipher, $this->getPublicKey($fingerprint)->getKeyString());
        return $cipher;
    }

Usage Example

 /**
  * @test
  */
 public function checkRSAEncryptedPasswordReturnsFalseForAnIncorrectPassword()
 {
     $encryptedPassword = $this->rsaWalletService->encryptWithPublicKey('wrong password', $this->keyPairUuid);
     $passwordHash = 'af1e8a52451786a6b3bf78838e03a0a2';
     $salt = 'a709157e66e0197cafa0c2ba99f6e252';
     $this->assertFalse($this->rsaWalletService->checkRSAEncryptedPassword($encryptedPassword, $passwordHash, $salt, $this->keyPairUuid));
 }