Open moszsiame opened 1 year ago
i'm trying to encrypt and sign from sample code
decrypt fine but verify fail.
my code `$config = $allConf[1]; $publicKeyPath = $config->publicKeyPath; $privateKeyPath = $config->privateKeyPath; $privateKeyPassphrase = $config->privateKeyPassphrase;
$recipientPublicKey = \OpenPGP_Message::parse(\OpenPGP::unarmor(file_get_contents($publicKeyPath), 'PGP PUBLIC KEY BLOCK')); $encryptedPrivateKey = \OpenPGP_Message::parse(\OpenPGP::unarmor(file_get_contents($privateKeyPath), 'PGP PRIVATE KEY BLOCK'));
$key = OpenPGP_Crypt_Symmetric::decryptSecretKey($privateKeyPassphrase, $encryptedPrivateKey[0]);
$signer = new OpenPGP_Crypt_RSA($key); $data = new OpenPGP_LiteralDataPacket("TEST TEXT"); $signed = $signer->sign($data);
//$compressed = new OpenPGP_CompressedDataPacket($signed);
//var_dump(new OpenPGP_Message([$compressed])); exit;
$encrypted = OpenPGP_Crypt_Symmetric::encrypt([$recipientPublicKey, $key], $signed);
var_dump(OpenPGP::enarmor($encrypted->to_bytes(), 'PGP MESSAGE'));`
this is command code in OPENPGP
gpg --pinentry-mode=loopback --passphrase "passphrase " --encrypt --sign -u "user_website_sign" --armor -r "user_website" "./test_file.txt"
i'm trying to encrypt and sign from sample code
decrypt fine but verify fail.
my code `$config = $allConf[1]; $publicKeyPath = $config->publicKeyPath; $privateKeyPath = $config->privateKeyPath; $privateKeyPassphrase = $config->privateKeyPassphrase;
$recipientPublicKey = \OpenPGP_Message::parse(\OpenPGP::unarmor(file_get_contents($publicKeyPath), 'PGP PUBLIC KEY BLOCK')); $encryptedPrivateKey = \OpenPGP_Message::parse(\OpenPGP::unarmor(file_get_contents($privateKeyPath), 'PGP PRIVATE KEY BLOCK'));
$key = OpenPGP_Crypt_Symmetric::decryptSecretKey($privateKeyPassphrase, $encryptedPrivateKey[0]);
$signer = new OpenPGP_Crypt_RSA($key); $data = new OpenPGP_LiteralDataPacket("TEST TEXT"); $signed = $signer->sign($data);
//$compressed = new OpenPGP_CompressedDataPacket($signed);
//var_dump(new OpenPGP_Message([$compressed])); exit;
$encrypted = OpenPGP_Crypt_Symmetric::encrypt([$recipientPublicKey, $key], $signed);
var_dump(OpenPGP::enarmor($encrypted->to_bytes(), 'PGP MESSAGE'));`