Security Zaawansowany

Encode and decode PEM-formatted cryptographic objects natively.

✕ Java 8
String pem = "-----BEGIN CERTIFICATE-----\n"
    + Base64.getMimeEncoder()
        .encodeToString(
            cert.getEncoded())
    + "\n-----END CERTIFICATE-----";
✓ Java 25 (Preview)
// Encode to PEM
String pem = PEMEncoder.of()
    .encodeToString(cert);
// Decode from PEM
var cert = PEMDecoder.of()
    .decode(pemString);
Widzisz problem z tym kodem? Daj nam znać.
🧹

No manual Base64

PEM headers, line wrapping, and Base64 handled automatically.

🔄

Bidirectional

Encode to PEM and decode from PEM with one API.

🛡️

Standard format

Produces RFC 7468-compliant PEM output.

Stare podejście
Manual Base64 + Headers
Nowoczesne podejście
PEM API
Od JDK
25
Poziom trudności
Zaawansowany
PEM encoding/decoding
Preview

Preview in JDK 25 (JEP 470). Requires --enable-preview.

The PEM API provides standard encoding/decoding for certificates, keys, and other cryptographic objects in PEM format. No more manual Base64 wrapping with BEGIN/END headers.

Udostępnij 𝕏 🦋 in