Java 27 and 26: runnable demos and captured output for every JEP, plus version lanes
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B38FGKKam5SCGgwgduVAh3
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
$ java --enable-preview PemDemo (JDK 27)
|
||||
--- public key, encoded
|
||||
-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----
|
||||
--- private key, encoded
|
||||
-----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----
|
||||
CHECK ok : a PublicKey encodes as BEGIN PUBLIC KEY
|
||||
CHECK ok : a PrivateKey encodes as BEGIN PRIVATE KEY (PKCS#8)
|
||||
CHECK ok : the decoded public key equals the original
|
||||
CHECK ok : the decoded private key equals the original
|
||||
--- decode(String) returns whatever the header says it is
|
||||
-----BEGIN PUBLIC KEY----- -> PublicKey (EC)
|
||||
-----BEGIN PRIVATE KEY----- -> PrivateKey (EC)
|
||||
--- encrypted private key
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
CHECK ok : withEncryption produces ENCRYPTED PRIVATE KEY
|
||||
decoded with no password: javax.crypto.EncryptedPrivateKeyInfo
|
||||
CHECK ok : without a password you get the still-encrypted structure back
|
||||
CHECK ok : with the password you get the original private key
|
||||
--- PEM(type, byte[]) does NOT Base64-encode: the bytes go in as they are
|
||||
-----BEGIN ANKURM DEMO-----
|
||||
hello, pem
|
||||
-----END ANKURM DEMO-----
|
||||
CHECK ok : raw bytes appear verbatim between the header and footer
|
||||
--- give it the Base64 text and it round-trips
|
||||
-----BEGIN ANKURM DEMO-----
|
||||
aGVsbG8sIHBlbQ==
|
||||
-----END ANKURM DEMO-----
|
||||
CHECK ok : type, Base64 text (content()) and decoded payload (decode()) all survive
|
||||
exit=0
|
||||
Reference in New Issue
Block a user