Open Petah opened 2 years ago
The key itself needs to be un-armored and parsed
$pubkey = './test-public-key.asc';
$pk = OpenPGP_Message::parse(\OpenPGP::unarmor(file_get_contents($pubkey), 'PGP PUBLIC KEY BLOCK'));
foreach ($pk->packets as $p) {
if (!($p instanceof \OpenPGP_PublicKeyPacket)) {
continue;
}
$publickeyPacket = $p;
}
$data = new OpenPGP_LiteralDataPacket("some text\n", ['format' => 'u']);
$encrypted = OpenPGP_Crypt_Symmetric::encrypt([$publickeyPacket], new OpenPGP_Message([$data]));
echo OpenPGP::enarmor($encrypted->to_bytes(), 'PGP MESSAGE');
Hi,
When trying to decrypt the output of this lib using gpg cli tool I get this:
This is the PHP code