1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-09 18:29:39 +02:00

Port ConvertKeys example

This commit is contained in:
Paul Schaub 2025-04-01 14:44:43 +02:00
parent a37f6dfce9
commit 41251296ce
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -20,17 +20,17 @@ public class ConvertKeys {
*/
@Test
public void secretKeyToCertificate() {
PGPainless api = PGPainless.getInstance();
String userId = "alice@wonderland.lit";
OpenPGPKey secretKey = PGPainless.generateKeyRing()
OpenPGPKey secretKey = api.generateKey()
.modernKeyRing(userId);
// Extract certificate (public key) from secret key
OpenPGPCertificate certificate = secretKey.toCertificate();
KeyRingInfo secretKeyInfo = PGPainless.inspectKeyRing(secretKey);
KeyRingInfo secretKeyInfo = api.inspect(secretKey);
assertTrue(secretKeyInfo.isSecretKey());
KeyRingInfo certificateInfo = PGPainless.inspectKeyRing(certificate);
KeyRingInfo certificateInfo = api.inspect(certificate);
assertFalse(certificateInfo.isSecretKey());
}
}