Neos\Flow\Security\Cryptography\RsaWalletServicePhp::decrypt PHP Method

decrypt() public method

Decrypts the given cipher with the private key identified by the given fingerprint Note: You should never decrypt a password with this function. Use checkRSAEncryptedPassword() to check passwords!
public decrypt ( string $cipher, string $fingerprint ) : string
$cipher string cipher text to decrypt
$fingerprint string The fingerprint to identify the private key (RSA public key fingerprint)
return string The decrypted text
    public function decrypt($cipher, $fingerprint)
    {
        if ($fingerprint === null || !isset($this->keys[$fingerprint])) {
            throw new InvalidKeyPairIdException('Invalid keypair fingerprint given', 1231438861);
        }
        $keyPair = $this->keys[$fingerprint];
        if ($keyPair['usedForPasswords']) {
            throw new DecryptionNotAllowedException('You are not allowed to decrypt passwords!', 1233655350);
        }
        return $this->decryptWithPrivateKey($cipher, $keyPair['privateKey']);
    }

Usage Example

 /**
  * @test
  * @expectedException \Neos\Flow\Security\Exception\DecryptionNotAllowedException
  */
 public function decryptingWithAKeypairUUIDMarkedForPasswordUsageThrowsAnException()
 {
     $this->keyPairUuid = $this->rsaWalletService->generateNewKeypair(true);
     $this->rsaWalletService->decrypt('some cipher', $this->keyPairUuid);
 }