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:
parent
a37f6dfce9
commit
41251296ce
1 changed files with 4 additions and 4 deletions
|
@ -20,17 +20,17 @@ public class ConvertKeys {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void secretKeyToCertificate() {
|
public void secretKeyToCertificate() {
|
||||||
|
PGPainless api = PGPainless.getInstance();
|
||||||
String userId = "alice@wonderland.lit";
|
String userId = "alice@wonderland.lit";
|
||||||
OpenPGPKey secretKey = PGPainless.generateKeyRing()
|
OpenPGPKey secretKey = api.generateKey()
|
||||||
.modernKeyRing(userId);
|
.modernKeyRing(userId);
|
||||||
|
|
||||||
// Extract certificate (public key) from secret key
|
// Extract certificate (public key) from secret key
|
||||||
OpenPGPCertificate certificate = secretKey.toCertificate();
|
OpenPGPCertificate certificate = secretKey.toCertificate();
|
||||||
|
|
||||||
|
KeyRingInfo secretKeyInfo = api.inspect(secretKey);
|
||||||
KeyRingInfo secretKeyInfo = PGPainless.inspectKeyRing(secretKey);
|
|
||||||
assertTrue(secretKeyInfo.isSecretKey());
|
assertTrue(secretKeyInfo.isSecretKey());
|
||||||
KeyRingInfo certificateInfo = PGPainless.inspectKeyRing(certificate);
|
KeyRingInfo certificateInfo = api.inspect(certificate);
|
||||||
assertFalse(certificateInfo.isSecretKey());
|
assertFalse(certificateInfo.isSecretKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue