Typorithm · medium

Symmetric vs Asymmetric

symmetric-asymmetricsecurityaesrsakeypair
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn Symmetric vs Asymmetric

0%

Cryptography

Symmetric crypto (AES) uses one shared secret key and is fast, good for bulk data. Asymmetric crypto (RSA/ECC) uses a public/private keypair for key exchange and signatures. Real systems are hybrid: asymmetric to exchange a fast symmetric session key.

Symmetric encryption uses a single secret key for both encryption and decryption. AES (here AES-256-CBC) is the standard; it is fast and ideal for encrypting large amounts of data, but both sides must already share the key.

Asymmetric encryption uses a keypair: a public key anyone can hold and a private key kept secret. Data encrypted with the public key can only be decrypted with the private key, and signatures work the reverse way — enabling key exchange and authentication without a pre-shared secret.

Asymmetric operations are slow, so real systems are hybrid: they use RSA or ECDH to securely agree on a random symmetric session key, then encrypt the actual traffic with fast AES. This is exactly how TLS sets up a connection.

01

Symmetric (AES): one shared key, fast, for bulk data.

02

Asymmetric (RSA/ECC): public/private keypair for exchange and signatures.

03

Hybrid: asymmetric exchanges a symmetric session key.

openssl enc -aes-256-cbc -in f.txt -out f.enc
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -pubout -out public.pem
openssl pkeyutl -encrypt -pubin -inkey public.pem

Read the implementation

Connect each part of the code to the concept before you type.

1. Symmetric encrypt

openssl enc -aes-256-cbc encrypts a file with AES using one shared secret key — fast, for bulk data.

openssl enc -aes-256-cbc -in f.txt -out f.enc

2. Generate keypair

genrsa creates a 2048-bit RSA private key; the matching public key is derived from it.

openssl genrsa -out private.pem 2048

3. Extract public key

-pubout writes only the public half, which you can share freely while the private key stays secret.

openssl rsa -in private.pem -pubout -out public.pem

4. Encrypt with public key

pkeyutl -encrypt -pubin encrypts with the public key so only the private-key holder can decrypt.

openssl pkeyutl -encrypt -pubin -inkey public.pem

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

Symmetric vs Asymmetric: Lesson & Practice · Typorithm | ApplyDjinn