Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encrypt and sign #134

Open
moszsiame opened this issue May 3, 2023 · 1 comment
Open

encrypt and sign #134

moszsiame opened this issue May 3, 2023 · 1 comment

Comments

@moszsiame
Copy link

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'));`

@moszsiame
Copy link
Author

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant