Public Key Encryption in Java: RSA, Hybrid Encryption and ML-KEM
How Java solves key distribution: RSA-OAEP encryption and its size limits, hybrid encryption that wraps an AES key, Diffie-Hellman key agreement with X25519 and HKDF, the KEM API with DHKEM, and post-quantum ML-KEM, with the parameter pitfalls that break interoperability.
kvi5hnuCode Sprout team member11 min readOn this page
The AES-GCM cipher from article 86 is fast and strong, but it has one weakness that no mode can fix: both sides must already share the secret key. If Alice could send Bob a key securely, Alice could probably send the message securely too. Public key (asymmetric) cryptography breaks this circle. Bob publishes a public key; anyone can use it to send Bob something that only Bob's private key can recover. This article covers the three ways Java offers to do that (RSA encryption, Diffie-Hellman key agreement, and key encapsulation mechanisms, including the post-quantum ML-KEM) and why all of them are used to move keys, not data.
RSA encryption
RSA encryption uses the same kind of key pair as RSA signatures, in the other direction: anyone encrypts with the public key, and only the private key decrypts.
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(3072);
KeyPair bob = kpg.generateKeyPair();
Cipher rsa = Cipher.getInstance("RSA/ECB/OAEPPadding");
rsa.init(Cipher.ENCRYPT_MODE, bob.getPublic(), new OAEPParameterSpec(
"SHA-256", "MGF1", MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT));
byte[] ciphertext = rsa.doFinal(smallSecret);
Things to know:
- Padding is essential. Use OAEP. The older PKCS #1 v1.5 encryption padding (which plain
Cipher.getInstance("RSA")selects) is vulnerable to padding-oracle attacks such as Bleichenbacher's and should be used only to read old data. Textbook RSA without padding is completely insecure. - Spell out the OAEP parameters. The JDK's
OAEPWithSHA-256AndMGF1Paddingtransformation uses SHA-256 for the main digest but SHA-1 inside the MGF1 mask function unless you pass anOAEPParameterSpec. Other libraries often use SHA-256 for both, and the mismatch makes decryption fail. Passing the spec explicitly, as above, avoids the surprise. - Size limits. RSA encrypts one block no larger than the key. With OAEP and SHA-256, a 3072-bit (384-byte) key can encrypt at most 384 − 2·32 − 2 = 318 bytes; one byte more throws
IllegalBlockSizeException. Every ciphertext is exactly as long as the key. - Speed. RSA private-key operations are thousands of times slower than AES on the same data.
- Randomized. OAEP mixes in random bytes, so encrypting the same message twice gives different ciphertexts, which prevents guessing attacks on short messages.
- Use 3072-bit keys for new systems (2048 is the minimum still accepted); 1024-bit keys are breakable.
Hybrid encryption
Because of the size limit and the speed, nobody encrypts documents with RSA directly. Instead, systems combine both kinds of cipher:
- The sender generates a random AES key, the data key.
- The sender encrypts the document with AES-GCM under the data key.
- The sender encrypts (wraps) the data key with the recipient's public key.
- The sender sends the wrapped key, the IV and the encrypted document.
- The recipient unwraps the data key with its private key and decrypts the document.
In Java, steps 3 and 5 use the cipher's wrap modes, which take and return Key objects directly:
// OAEP_SHA256 is the OAEPParameterSpec from the previous section
Cipher c = Cipher.getInstance("RSA/ECB/OAEPPadding");
c.init(Cipher.WRAP_MODE, recipientPublicKey, OAEP_SHA256);
byte[] wrapped = c.wrap(dataKey);
...
c.init(Cipher.UNWRAP_MODE, recipientPrivateKey, OAEP_SHA256);
SecretKey dataKey = (SecretKey) c.unwrap(wrapped, "AES", Cipher.SECRET_KEY);
Only 32 bytes ever go through RSA, whatever the size of the document. This is how encrypted e-mail (S/MIME, OpenPGP) and many file encryption tools work.
Key agreement: Diffie-Hellman
A second approach does not encrypt a key at all. In a key agreement such as Diffie-Hellman, each side combines its own private key with the other side's public key, and both arrive at the same shared secret, which an eavesdropper who saw only the public keys cannot compute. TLS 1.3 sets up every connection this way, usually with fresh ("ephemeral") key pairs per connection, so that a later theft of a server's long-term key does not expose old sessions (forward secrecy).
KeyAgreement ka = KeyAgreement.getInstance("X25519"); // or "ECDH", "X448", "DH"
ka.init(myPrivateKey);
ka.doPhase(theirPublicKey, true);
byte[] shared = ka.generateSecret();
The raw shared secret is not uniformly random and must not be used as a key directly. Run it through a key derivation function, typically HKDF from the KDF API (Java 25), with a context string that names the purpose:
SecretKey aesKey = KDF.getInstance("HKDF-SHA256").deriveKey("AES",
HKDFParameterSpec.ofExtract().addIKM(shared).thenExpand("chat v1 aes key".getBytes(), 32));
X25519 and X448 (Java 11, RFC 7748) are the modern curves; ECDH with secp256r1 is common in older protocols. Note that a bare key agreement does not tell you who you agreed with: the public keys must be authenticated, for example with certificates and signatures, or a man in the middle can agree on one secret with each side.
Key encapsulation mechanisms (KEM)
A KEM packages the "send a fresh secret key to the holder of a public key" step into one clean operation, and since Java 21 (JEP 452) the JDK has an API for it, javax.crypto.KEM:

KEM kem = KEM.getInstance("ML-KEM");
// Sender: only needs the receiver's public key
KEM.Encapsulator enc = kem.newEncapsulator(receiverPublicKey);
KEM.Encapsulated e = enc.encapsulate();
SecretKey key = e.key(); // use it with AES-GCM
byte[] encapsulation = e.encapsulation(); // send this to the receiver
// Receiver
SecretKey same = kem.newDecapsulator(receiverPrivateKey).decapsulate(encapsulation);
Unlike wrapping, the sender does not choose the key: the KEM generates it together with the encapsulation, which removes a whole class of mistakes (weak keys, bad padding). encapsulate(from, to, algorithm) and decapsulate(encapsulation, from, to, algorithm) return a slice of the secret labelled with an algorithm name such as "AES". secretSize() and encapsulationSize() report the sizes.
The JDK provides two KEMs:
| KEM | Since | Keys | Notes |
|---|---|---|---|
DHKEM | Java 21 | X25519, X448, EC P-256/384/521 | Diffie-Hellman packaged as a KEM, as specified for HPKE (RFC 9180). |
ML-KEM | Java 24 (JEP 496) | ML-KEM-512, ML-KEM-768, ML-KEM-1024 | Module-lattice KEM standardized in FIPS 203. Resistant to quantum computers. |
Why ML-KEM matters now
A sufficiently large quantum computer could break RSA, Diffie-Hellman and elliptic curves. For encryption the threat is already present: an attacker can record encrypted traffic today and decrypt it once such a machine exists ("harvest now, decrypt later"). Data that must stay secret for ten years or more needs post-quantum key establishment now. ML-KEM-768 is the parameter set most deployments choose; its public key is 1,184 bytes and its encapsulation 1,088 bytes, compared with 32 bytes for X25519.
Because ML-KEM is young, the usual practice is a hybrid key exchange that combines X25519 and ML-KEM-768 and derives the session key from both secrets, so the result is safe as long as either algorithm holds. Major browsers and TLS libraries have used such a hybrid (X25519MLKEM768) by default since 2024–2025.
Which one should I use?
- To encrypt data for a recipient's public key: a KEM (ML-KEM, or a hybrid with DHKEM) plus AES-GCM. RSA-OAEP key wrapping remains acceptable for compatibility with existing formats.
- For a live, interactive connection: use TLS (
HttpClient,SSLSocket) rather than building your own; it already performs authenticated key agreement. - For two parties who already authenticate each other's public keys: X25519 key agreement plus HKDF.
- Never: RSA without OAEP, RSA keys under 2048 bits, or raw shared secrets used directly as keys.
The program
The program encrypts a short message with RSA-OAEP and probes its size limit, wraps an AES key with RSA for hybrid encryption of a 110 KB document, performs an X25519 key agreement and derives an AES key with HKDF, runs DHKEM and ML-KEM-768 through the KEM API, encrypts a message with an ML-KEM secret, and finally shows implicit rejection. All keys are random, so the program prints only sizes and checks, which are the same on every run.
import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.spec.*;
import java.util.*;
import javax.crypto.*;
import javax.crypto.spec.*;
public class Solution {
static final SecureRandom RANDOM = new SecureRandom();
static byte[] utf8(String s) { return s.getBytes(StandardCharsets.UTF_8); }
static String text(byte[] b) { return new String(b, StandardCharsets.UTF_8); }
static byte[] gcm(int mode, SecretKey key, byte[] iv, byte[] data) throws GeneralSecurityException {
Cipher c = Cipher.getInstance("AES/GCM/NoPadding");
c.init(mode, key, new GCMParameterSpec(128, iv));
return c.doFinal(data);
}
/** RSA-OAEP with SHA-256 for both the OAEP digest and MGF1, spelled out for interoperability. */
static final OAEPParameterSpec OAEP_SHA256 = new OAEPParameterSpec(
"SHA-256", "MGF1", MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT);
static Cipher rsaOaep(int mode, Key key) throws GeneralSecurityException {
Cipher c = Cipher.getInstance("RSA/ECB/OAEPPadding");
c.init(mode, key, OAEP_SHA256);
return c;
}
public static void main(String[] args) throws Exception {
byte[] secretMessage = utf8("The meeting moves to Thursday, 10:00, room 4.");
System.out.println("== RSA-OAEP: encrypting directly with a public key ==");
var kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(3072);
KeyPair bob = kpg.generateKeyPair();
Cipher rsa = rsaOaep(Cipher.ENCRYPT_MODE, bob.getPublic());
byte[] c1 = rsa.doFinal(secretMessage);
byte[] c2 = rsa.doFinal(secretMessage);
System.out.println(secretMessage.length + " bytes in -> " + c1.length + " bytes out; same input twice differs: " + !Arrays.equals(c1, c2));
System.out.println("decrypted: " + text(rsaOaep(Cipher.DECRYPT_MODE, bob.getPrivate()).doFinal(c1)));
int max = 384 - 2 * 32 - 2;
System.out.println("largest plaintext for 3072-bit RSA-OAEP-SHA256: " + rsa.doFinal(new byte[max]).length + "-byte output from " + max + " bytes");
try {
rsa.doFinal(new byte[max + 1]);
} catch (IllegalBlockSizeException e) {
System.out.println(max + 1 + " bytes: " + e.getClass().getSimpleName());
}
System.out.println("\n== Hybrid encryption: RSA wraps an AES key, AES-GCM encrypts the data ==");
byte[] bigDocument = utf8("quarterly figures ... ".repeat(5000));
// Alice (sender) has only Bob's public key
SecretKey dataKey = KeyGenerator.getInstance("AES").generateKey();
byte[] wrappedKey = rsaOaep(Cipher.WRAP_MODE, bob.getPublic()).wrap(dataKey);
byte[] iv = new byte[12];
RANDOM.nextBytes(iv);
byte[] body = gcm(Cipher.ENCRYPT_MODE, dataKey, iv, bigDocument);
System.out.println("sent: wrapped key " + wrappedKey.length + " + IV " + iv.length + " + body " + body.length + " bytes");
// Bob unwraps with his private key
var recovered = (SecretKey) rsaOaep(Cipher.UNWRAP_MODE, bob.getPrivate())
.unwrap(wrappedKey, "AES", Cipher.SECRET_KEY);
byte[] opened = gcm(Cipher.DECRYPT_MODE, recovered, iv, body);
System.out.println("Bob decrypts " + opened.length + " bytes; equal: " + Arrays.equals(bigDocument, opened));
System.out.println("\n== Key agreement: X25519 Diffie-Hellman ==");
KeyPairGenerator xg = KeyPairGenerator.getInstance("X25519");
KeyPair alicePair = xg.generateKeyPair(), bobPair = xg.generateKeyPair();
KeyAgreement ka = KeyAgreement.getInstance("X25519");
ka.init(alicePair.getPrivate());
ka.doPhase(bobPair.getPublic(), true);
byte[] aliceSecret = ka.generateSecret();
ka.init(bobPair.getPrivate());
ka.doPhase(alicePair.getPublic(), true);
byte[] bobSecret = ka.generateSecret();
System.out.println("both sides computed the same " + aliceSecret.length + "-byte secret: " + Arrays.equals(aliceSecret, bobSecret));
KDF hkdf = KDF.getInstance("HKDF-SHA256");
SecretKey sessionKey = hkdf.deriveKey("AES", HKDFParameterSpec.ofExtract()
.addIKM(aliceSecret).thenExpand(utf8("demo chat v1 / aes key"), 32));
System.out.println("session key from HKDF: " + sessionKey.getAlgorithm() + ", " + sessionKey.getEncoded().length * 8 + " bits");
System.out.println("\n== The KEM API (Java 21): DHKEM over X25519 ==");
demoKem("DHKEM", bobPair);
System.out.println("\n== Post-quantum: ML-KEM (Java 24) ==");
KeyPairGenerator mlg = KeyPairGenerator.getInstance("ML-KEM");
mlg.initialize(NamedParameterSpec.ML_KEM_768);
KeyPair bobPq = mlg.generateKeyPair();
demoKem("ML-KEM", bobPq);
System.out.println("\n== Encrypting a message with a KEM secret ==");
KEM kem = KEM.getInstance("ML-KEM");
KEM.Encapsulated sent = kem.newEncapsulator(bobPq.getPublic()).encapsulate(0, 32, "AES");
byte[] nonce = new byte[12];
RANDOM.nextBytes(nonce);
byte[] sealed = gcm(Cipher.ENCRYPT_MODE, sent.key(), nonce, secretMessage);
SecretKey bobKey = kem.newDecapsulator(bobPq.getPrivate()).decapsulate(sent.encapsulation(), 0, 32, "AES");
System.out.println("Bob reads: " + text(gcm(Cipher.DECRYPT_MODE, bobKey, nonce, sealed)));
byte[] damaged = sent.encapsulation().clone();
damaged[0] ^= 1;
SecretKey wrongKey = kem.newDecapsulator(bobPq.getPrivate()).decapsulate(damaged, 0, 32, "AES");
try {
gcm(Cipher.DECRYPT_MODE, wrongKey, nonce, sealed);
} catch (AEADBadTagException e) {
System.out.println("damaged encapsulation -> different key (implicit rejection) -> " + e.getClass().getSimpleName());
}
}
static void demoKem(String alg, KeyPair receiver) throws GeneralSecurityException {
KEM kem = KEM.getInstance(alg);
// Sender: needs only the receiver's public key
KEM.Encapsulator enc = kem.newEncapsulator(receiver.getPublic());
KEM.Encapsulated result = enc.encapsulate();
SecretKey senderKey = result.key();
byte[] encapsulation = result.encapsulation();
// Receiver: recovers the same key from the encapsulation with the private key
KEM.Decapsulator dec = kem.newDecapsulator(receiver.getPrivate());
SecretKey receiverKey = dec.decapsulate(encapsulation);
System.out.printf("%s: public key %d bytes, encapsulation %d bytes, shared secret %d bytes, keys equal: %s%n",
alg, receiver.getPublic().getEncoded().length, encapsulation.length, senderKey.getEncoded().length,
Arrays.equals(senderKey.getEncoded(), receiverKey.getEncoded()));
System.out.println(" sizes reported by the API: secretSize=" + enc.secretSize() + ", encapsulationSize=" + enc.encapsulationSize());
}
}
== RSA-OAEP: encrypting directly with a public key ==
45 bytes in -> 384 bytes out; same input twice differs: true
decrypted: The meeting moves to Thursday, 10:00, room 4.
largest plaintext for 3072-bit RSA-OAEP-SHA256: 384-byte output from 318 bytes
319 bytes: IllegalBlockSizeException
== Hybrid encryption: RSA wraps an AES key, AES-GCM encrypts the data ==
sent: wrapped key 384 + IV 12 + body 110016 bytes
Bob decrypts 110000 bytes; equal: true
== Key agreement: X25519 Diffie-Hellman ==
both sides computed the same 32-byte secret: true
session key from HKDF: AES, 256 bits
== The KEM API (Java 21): DHKEM over X25519 ==
DHKEM: public key 44 bytes, encapsulation 32 bytes, shared secret 32 bytes, keys equal: true
sizes reported by the API: secretSize=32, encapsulationSize=32
== Post-quantum: ML-KEM (Java 24) ==
ML-KEM: public key 1206 bytes, encapsulation 1088 bytes, shared secret 32 bytes, keys equal: true
sizes reported by the API: secretSize=32, encapsulationSize=1088
== Encrypting a message with a KEM secret ==
Bob reads: The meeting moves to Thursday, 10:00, room 4.
damaged encapsulation -> different key (implicit rejection) -> AEADBadTagException
Points to notice:
- The RSA ciphertext is always 384 bytes for a 3072-bit key, whether the input is 45 or 318 bytes.
- The hybrid message costs only 384 + 12 + 16 bytes of overhead on top of the 110,000-byte document.
- The ML-KEM public key is 1,206 bytes in its X.509 encoding (1,184 bytes of key plus a 22-byte header), roughly 27 times larger than the 44-byte X25519 encoding.
Common questions
Can I encrypt a large file with RSA? No. RSA-OAEP with a 3072-bit key encrypts at most a few hundred bytes. Encrypt the file with AES-GCM and the AES key with RSA (hybrid encryption), or use a KEM.
Should I use RSA key wrapping, ECDH or a KEM? For new designs, a KEM (DHKEM with X25519, or ML-KEM, ideally a hybrid of both) gives the cleanest API and avoids padding pitfalls. ECDH is what protocols such as TLS use internally. RSA-OAEP wrapping remains common for compatibility with existing systems and hardware.
Is ML-KEM available in all Java versions?
ML-KEM and ML-DSA are in the JDK since Java 24 (JEPs 496 and 497). The KEM API itself came in Java 21. On older versions, use Bouncy Castle.
Do I need post-quantum crypto now? For data that must remain confidential for many years, yes: recorded traffic could be decrypted later. TLS in current browsers and servers already uses hybrid ML-KEM key exchange. For signatures, there is less urgency, since a forged signature needs a quantum computer at verification time.
Why does Cipher.getInstance("RSA") work but get flagged in code reviews?
It defaults to RSA/ECB/PKCS1Padding, which is vulnerable to padding-oracle attacks (Bleichenbacher). Use RSA/ECB/OAEPPadding with an explicit OAEPParameterSpec (SHA-256 for both the digest and MGF1), as shown above; the shorthand OAEPWithSHA-256AndMGF1Padding silently uses SHA-1 inside MGF1 in SunJCE. (The "ECB" is just a name; RSA has no block mode.)
API reference
| Class / method | Purpose |
|---|---|
Cipher.getInstance("RSA/ECB/OAEPPadding") + OAEPParameterSpec | RSA-OAEP encryption with explicit digests. |
Cipher.WRAP_MODE / UNWRAP_MODE, wrap(key), unwrap(bytes, alg, Cipher.SECRET_KEY) | Encrypt and decrypt keys. |
KeyPairGenerator.getInstance("RSA" / "X25519" / "ML-KEM") | Key pairs; initialize(3072) or initialize(NamedParameterSpec.ML_KEM_768). |
KeyAgreement.getInstance("X25519"), init, doPhase, generateSecret | Diffie-Hellman key agreement. |
KDF.getInstance("HKDF-SHA256"), HKDFParameterSpec, deriveKey | Turn a shared secret into keys (Java 25). |
KEM.getInstance("ML-KEM" / "DHKEM") | Key encapsulation (Java 21; ML-KEM Java 24). |
newEncapsulator(publicKey), encapsulate([from, to, alg]) | Sender side; returns KEM.Encapsulated with key() and encapsulation(). |
newDecapsulator(privateKey), decapsulate(bytes [, from, to, alg]) | Receiver side. |
secretSize(), encapsulationSize() | Sizes for buffer planning. |
Summary
- Public key encryption solves key distribution: anyone can encrypt for Bob's public key; only Bob's private key recovers the result.
- RSA must use OAEP; specify
OAEPParameterSpecexplicitly to avoid the SHA-1 MGF1 default. It encrypts at most a few hundred bytes and is slow, so it wraps symmetric keys instead of data. - Hybrid encryption combines a public key step for a random AES key with AES-GCM for the data.
- Diffie-Hellman (X25519) lets two parties derive a shared secret; always pass it through HKDF and authenticate the public keys.
- The KEM API (Java 21) generates and encapsulates a fresh key in one step.
ML-KEM(Java 24) adds post-quantum security; hybrids with X25519 are the current deployment practice.
Practice Questions
1. A Java service encrypts with RSA/ECB/OAEPWithSHA-256AndMGF1Padding and a partner's Python service cannot decrypt the messages. What is the likely cause and the fix?
SunJCE's OAEPWithSHA-256AndMGF1Padding uses SHA-256 for the OAEP hash but SHA-1 for MGF1 by default, while many other libraries use SHA-256 for both. Initialize the cipher with an explicit OAEPParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT) (or whatever both sides agree on), so the parameters match on both ends.
2. Why can't you encrypt a 10 KB file with RSA-OAEP directly, and what do you do instead?
RSA encrypts a single block smaller than the key: at most 318 bytes for a 3072-bit key with OAEP-SHA256. Splitting the file into many RSA blocks would be very slow and is not a secure construction. Use hybrid encryption: encrypt the file with AES-GCM under a random key, and encrypt only that key with RSA-OAEP (or obtain it from a KEM).
3. Two parties compute an X25519 shared secret and use its 32 bytes directly as an AES-256 key. Name two problems.
First, the raw output of Diffie-Hellman is not a uniformly random string, so it should go through a KDF such as HKDF, which also lets you bind the key to a purpose and derive several keys. Second, if the public keys were not authenticated, a man in the middle could run a separate agreement with each side and read everything; the exchange needs certificates or signatures (as TLS uses) to know who you agreed with.
4. What does "harvest now, decrypt later" mean, and why does it make post-quantum key exchange more urgent than post-quantum signatures?
An attacker records encrypted traffic today and stores it until a quantum computer can break the key exchange, then decrypts it. Secrets with a long life are therefore at risk already, even before such a computer exists. A forged signature, by contrast, only matters if it can be created while the signature is still being trusted, so the threat to signatures starts when the quantum computer arrives. That is why hybrid ML-KEM key exchange was deployed in browsers first.
5. An ML-KEM decapsulation of a corrupted encapsulation returns a key without throwing. Is that a bug?
No, it is "implicit rejection", part of the ML-KEM design. Returning a pseudo-random key instead of an error gives an attacker no information from which to learn about the private key. The mismatch is detected when the derived key is used: the AES-GCM tag check fails with AEADBadTagException. This is why a KEM should always be combined with authenticated encryption.
Previous: Symmetric Encryption in Java: AES-GCM, Key Generation and Cipher Streams
Next: Java GUI Toolkits and Your First JFrame: AWT, Swing and JavaFX
Related reading
- Symmetric Encryption in Java: AES-GCM, Key Generation and Cipher Streams
- Certificates in Java: keytool, Certificate Chains and Signing JAR Files
- Digital Signatures in Java: Signing and Verifying with RSA, EdDSA and ML-DSA
- Message Digests and Password Hashing in Java: SHA-2, SHA-3 and PBKDF2
- User Authentication with JAAS in Java: Login Modules, Callbacks and Subjects

More in Core Java II
FFM Upcalls, Variadic Functions and errno
Advanced FFM calls: passing Java code to C as function pointers with upcall stubs, binding objects and lambdas, calling variadic functions such as printf, capturing errno and GetLastError, and a C library that calls back into Java. The final article of the course.
Calling Foreign Functions: Linker, Symbol Lookup, Downcalls and jextract
Calling C functions from pure Java with the FFM API: the native linker, default, library and loader symbol lookups, function descriptors, downcall handles, invokeExact, pointers and NULL, struct results, critical calls, enabling native access, and generating bindings with jextract.
FFM Memory Layouts: Structs, Unions, Sequences and Var Handles
Describing C data with FFM memory layouts: value layouts and C types, struct and union layouts, alignment and padding, sequences, layout paths, var handles with base offsets, offset and slice handles, pointers with target layouts, and atomic access modes.
Foreign Function and Memory API: Arenas and Memory Segments
Getting started with the FFM API (final since Java 22): a first foreign call, confined, shared, automatic and global arenas, native and heap memory segments, reading and writing values, C strings and arrays, alignment and byte order, slices, copies, allocators, and memory-mapped files.
Discussion
Sign in to ask a question or share what you learned.