I am trying to generate a key pair with bouncy castle pgp. I use this example:http://grepcode.com/file/repo1.maven.org/maven2/org.bouncycastle/bcpg-jdk15/1.45/org/bouncycastle/openpgp/examples/RSAKeyPairGenerator.java
But I've had an error I can't understand/ resolve on the line
PGPSecretKey secretKey = new PGPSecretKey(PGPSignature.DEFAULT_CERTIFICATION, PGPPublicKey.RSA_GENERAL, publicKey, privateKey, new Date(), identity, PGPEncryptedData.CAST5, passPhrase, null, null, new SecureRandom(), "BC");
Cannot resolve the constructor... But if I look at the java doc it seems alright to me...
compiler error
Error:(43, 37) java: no suitable constructor found for PGPSecretKey(int,int,java.security.PublicKey,java.security.PrivateKey,java.util.Date,java.lang.String,int,char[],<nulltype>,<nulltype>,java.security.SecureRandom,java.lang.String)
constructor org.bouncycastle.openpgp.PGPSecretKey.PGPSecretKey(org.bouncycastle.bcpg.SecretKeyPacket,org.bouncycastle.openpgp.PGPPublicKey) is not applicable
(actual and formal argument lists differ in length)
constructor org.bouncycastle.openpgp.PGPSecretKey.PGPSecretKey(org.bouncycastle.openpgp.PGPPrivateKey,org.bouncycastle.openpgp.PGPPublicKey,org.bouncycastle.openpgp.operator.PGPDigestCalculator,org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor) is not applicable
(actual and formal argument lists differ in length)
constructor org.bouncycastle.openpgp.PGPSecretKey.PGPSecretKey(org.bouncycastle.openpgp.PGPPrivateKey,org.bouncycastle.openpgp.PGPPublicKey,org.bouncycastle.openpgp.operator.PGPDigestCalculator,boolean,org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor) is not applicable
(actual and formal argument lists differ in length)
constructor org.bouncycastle.openpgp.PGPSecretKey.PGPSecretKey(int,org.bouncycastle.openpgp.PGPKeyPair,java.lang.String,org.bouncycastle.openpgp.PGPSignatureSubpacketVector,org.bouncycastle.openpgp.PGPSignatureSubpacketVector,org.bouncycastle.openpgp.operator.PGPContentSignerBuilder,org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor) is not applicable
(actual and formal argument lists differ in length)
constructor org.bouncycastle.openpgp.PGPSecretKey.PGPSecretKey(int,org.bouncycastle.openpgp.PGPKeyPair,java.lang.String,org.bouncycastle.openpgp.operator.PGPDigestCalculator,org.bouncycastle.openpgp.PGPSignatureSubpacketVector,org.bouncycastle.openpgp.PGPSignatureSubpacketVector,org.bouncycastle.openpgp.operator.PGPContentSignerBuilder,org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor) is not applicable
(actual and formal argument lists differ in length)
thanks
You are using version 1.45, which is quite old, the current version is 1.58.
As @Hulk correctly surmised, you appear to be referring to the Javadoc for a much later version, which has a 12-argument constructor. This constructor does not exist in 1.45.
Update your POM to reference version 1.58 instead.