neuhalje / bouncy-gpg

Make using Bouncy Castle with OpenPGP fun again!
https://neuhalje.github.io/bouncy-gpg/
Other
205 stars 58 forks source link

unable to encrypt a file with recipient as any string (example : 918A6B32) instead of email. #83

Open npnaidu206 opened 2 months ago

npnaidu206 commented 2 months ago

When we use below java snippet , it works for recipient as email but does not work for any random string. BouncyGPG .encryptToStream() .withConfig(keyringConfig) .withStrongAlgorithms() .toRecipient(recipient) .andDoNotSign() .armorAsciiOutput() .andWriteTo(output) System (please complete the following information):

throws exception :"org.bouncycastle.openpgp.PGPException: No (suitable) public key for encryption to 918A6B32 found\n\tat name.neuhalfen.projects.crypto.bouncycastle.openpgp.BuildEncryptionOutputStreamAPI$WithAlgorithmSuiteImpl$ToImpl.extractValidKey(BuildEncryptionOutputStreamAPI.java:414)\n\tat name.neuhalfen.projects.crypto.bouncycastle.openpgp.BuildEncryptionOutputStreamAPI$WithAlgorithmSuiteImpl$ToImpl.toRecipient(BuildEncryptionOutputStreamAPI.java:431.

Where as it works for command line : gpg --output /tmp/outputfile.txt.pgp --reciepient 918A6B32 --encrypt textfilePath

please let me know if it is issue with bouncy gpg issue ?

thanks for your help. looking forward for reply

npnaidu206 commented 2 months ago

using

name.neuhalfen.projects.crypto.bouncycastle.openpgp
        <artifactId>bouncy-gpg</artifactId>
        <version>2.3.0</version>
    </dependency>