{"action":"created","issue":{"url":"https://api.github.com/repos/singpolyma/openpgp-php/issues/75","repository_url":"https://api.github.com/repos/singpolyma/openpgp-php","labels_url":"https://api.github.com/repos/singpolyma/openpgp-php/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/singpolyma/openpgp-php/issues/75/comments","events_url":"https://api.github.com/repos/singpolyma/openpgp-php/issues/75/events","html_url":"https://github.com/singpolyma/openpgp-php/issues/75","id":380990867,"node_id":"MDU6SXNzdWUzODA5OTA4Njc=","number":75,"title":"How to encrypt with a public key which are protected by a passphrase?","user":{"login":"leejie8008","id":18082103,"node_id":"MDQ6VXNlcjE4MDgyMTAz","avatar_url":"https://avatars3.githubusercontent.com/u/18082103?v=4","gravatar_id":"","url":"https://api.github.com/users/leejie8008","html_url":"https://github.com/leejie8008","followers_url":"https://api.github.com/users/leejie8008/followers","following_url":"https://api.github.com/users/leejie8008/following{/other_user}","gists_url":"https://api.github.com/users/leejie8008/gists{/gist_id}","starred_url":"https://api.github.com/users/leejie8008/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leejie8008/subscriptions","organizations_url":"https://api.github.com/users/leejie8008/orgs","repos_url":"https://api.github.com/users/leejie8008/repos","events_url":"https://api.github.com/users/leejie8008/events{/privacy}","received_events_url":"https://api.github.com/users/leejie8008/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-15T04:03:03Z","updated_at":"2018-11-21T00:56:31Z","closed_at":null,"author_association":"NONE","body":"I am trying to encrypt and decrypt with public and private key which are protected by a passphrase. The decrypt result is always showing `null`, and it might be because that the keys are protected by passphrase.\r\n\r\nBelow are my implementation for the encrypt and decryption. I get `Encryption Error` at line `$decrypted = $decryptor->decrypt($encrypted);` with this implementation\r\n\r\n`$message = 'Test Text';`\r\n\r\n`$pathToYourAsciiArmoredPublicKey = base_path('public.asc');`\r\n`$pathToYourAsciiArmoredPrivateKey = base_path('private.asc');`\r\n\r\n`$key=OpenPGP_Message::parse(OpenPGP::unarmor(file_get_contents($pathToYourAsciiArmoredPublicKey),'PGP PUBLIC KEY BLOCK'));`\r\n\r\n`$data = new \\OpenPGP_LiteralDataPacket($message);`\r\n\r\n`$encrypted = \\OpenPGP_Crypt_Symmetric::encrypt($key,new OpenPGP_Message(array($data)));`\r\n`\r\n$encryptedPrivateKey=OpenPGP_Message::parse(OpenPGP::unarmor(file_get_contents($pathToYourAsciiArmoredPrivateKey),'PGP PRIVATE KEY BLOCK'));`\r\n\r\n`foreach ($encryptedPrivateKey as $package) {`\r\n     `$key = OpenPGP_Crypt_Symmetric::decryptSecretKey('password', $package);`\r\n     `$decryptor = new OpenPGP_Crypt_RSA($key);`\r\n     `$decrypted = $decryptor->decrypt($encrypted);`\r\n     `var_dump($decrypted);`\r\n`}`\r\n\r\nFrom what I found is, it already combine both together at `openpgp_crypt_symmetric.php`\r\n\r\n` public static function encrypt($passphrases_and_keys, $message, $symmetric_algorithm=9) {`\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/singpolyma/openpgp-php/issues/comments/440487590","html_url":"https://github.com/singpolyma/openpgp-php/issues/75#issuecomment-440487590","issue_url":"https://api.github.com/repos/singpolyma/openpgp-php/issues/75","id":440487590,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDQ4NzU5MA==","user":{"login":"singpolyma","id":12770,"node_id":"MDQ6VXNlcjEyNzcw","avatar_url":"https://avatars2.githubusercontent.com/u/12770?v=4","gravatar_id":"","url":"https://api.github.com/users/singpolyma","html_url":"https://github.com/singpolyma","followers_url":"https://api.github.com/users/singpolyma/followers","following_url":"https://api.github.com/users/singpolyma/following{/other_user}","gists_url":"https://api.github.com/users/singpolyma/gists{/gist_id}","starred_url":"https://api.github.com/users/singpolyma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/singpolyma/subscriptions","organizations_url":"https://api.github.com/users/singpolyma/orgs","repos_url":"https://api.github.com/users/singpolyma/repos","events_url":"https://api.github.com/users/singpolyma/events{/privacy}","received_events_url":"https://api.github.com/users/singpolyma/received_events","type":"User","site_admin":false},"created_at":"2018-11-21T00:56:31Z","updated_at":"2018-11-21T00:56:31Z","author_association":"OWNER","body":"Have you done `var_dump($key)` after the `decryptSecretKey` call to make sure it is decrypting correctly?\r\n\r\nAlso, is the key an RSA key?"}}
{"actor":{"display_login":"singpolyma"}}