Closed alonsoir closed 3 years ago
If you want to encrypt without signing, set the signing algorithm to unsigned:
encryptor.setSigningAlgorithm(HashingAlgorithm.Unsigned);
If you want to encrypt and sign with the same key, you need to the keypair's secret key (export it from gpg
with the --export-secret-keys
flag), and you also need to supply its passphrase:
new Encryptor(new Key(new File("src/main/resources/secret-key.gpg"), "password123"))
I can encrypt the file using unsigned. It is ok for me. Now I have to decrypt the same file, but that is another question.
Hi Justin,
I've been looking at how to use your library to encrypt avro messages, and when launching my code, an exception appears:
Exception in thread "main" org.bouncycastle.openpgp.PGPException: no suitable signing key found at org.c02e.jpgpj.Encryptor.sign(Encryptor.java:982) at org.c02e.jpgpj.Encryptor.prepareCiphertextOutputStream(Encryptor.java:773) at org.c02e.jpgpj.Encryptor.encrypt(Encryptor.java:691) at org.c02e.jpgpj.Encryptor.encrypt(Encryptor.java:662) at avro.EncryptPayload$.main(EncryptPayload.scala:40) at avro.EncryptPayload.main(EncryptPayload.scala)
I have created the pair of keys using gpg:
gpg --gen-key
gpg --armor --output public-key.gpg --export my-email@gmail.com
Then I exported public-key.gpg to src/main/resources and compile this code
Could you help me?