What Is Symmetric vs Asymmetric Encryption? Examples With OpenSSL, age, and Other Security Tools

Use symmetric encryption for speed, and asymmetric encryption for safer key exchange. That is the practical split. Symmetric tools use one secret key to lock and unlock data. Asymmetric tools use a public key to encrypt and a private key to decrypt. AES, one of the most common symmetric ciphers, supports 128, 192, and 256-bit keys as defined by NIST [source: NIST].

TLDR: Symmetric encryption is fast and good for files, backups, and disks. Asymmetric encryption is slower, but it solves the annoying problem of sharing secrets with someone who is not in the same room. For example, a 2 GB backup should be encrypted with a symmetric tool, while the backup key can be protected with the recipient’s public key. In most real systems, both are used together: asymmetric encryption protects the key, and symmetric encryption protects the data.

Symmetric encryption: one key, fast results

Symmetric encryption means the same secret is used for encryption and decryption. If Alice encrypts a file with a password or key, Bob needs that same password or key to open it.

This is why symmetric encryption is common in:

  • Full disk encryption, such as BitLocker, FileVault, and LUKS.
  • Encrypted backups, where large amounts of data must be processed quickly.
  • VPN tunnels and TLS sessions after a secure session key is created.
  • Local file protection for archives, exports, and reports.

The catch is simple: key sharing is painful. If you send the password by email, chat, or ticket comment, you may have just weakened the whole setup. It drives me crazy that teams still paste encryption passwords into the same systems that hold the encrypted files.

OpenSSL symmetric example

This OpenSSL command encrypts a file using AES-256-CBC with a password-based key:

openssl enc -aes-256-cbc -salt -pbkdf2 -iter 600000 \
  -in report.pdf \
  -out report.pdf.enc

To decrypt it:

openssl enc -d -aes-256-cbc -pbkdf2 -iter 600000 \
  -in report.pdf.enc \
  -out report.pdf

This is useful for quick local encryption, but be careful. CBC mode does not give modern authenticated encryption by itself. That means tampering may not be detected as cleanly as you expect. For routine file encryption, age is usually cleaner and harder to misuse.

age symmetric example

age is a modern file encryption tool with a small command set. To encrypt a file with a passphrase:

age -p -o secrets.txt.age secrets.txt

To decrypt it:

age -d -o secrets.txt secrets.txt.age

The prompts are simple. The output is portable. Honestly, it feels like the tool was built by someone who got tired of arguing with old crypto flags.

Asymmetric encryption: public key locks, private key opens

Asymmetric encryption uses a key pair. The public key can be shared with anyone. The private key must stay secret.

If Alice wants to send Bob a secret, she encrypts it with Bob’s public key. Only Bob’s private key can decrypt it. This is useful when people or systems need to exchange data without first sharing a password.

Common uses include:

  • SSH keys for server login.
  • TLS certificates for website identity and secure sessions.
  • Email encryption with OpenPGP or S/MIME.
  • Software signing, where a private key signs and a public key verifies.

OpenSSL asymmetric example

Generate an RSA private key:

openssl genpkey -algorithm RSA \
  -pkeyopt rsa_keygen_bits:3072 \
  -out private.pem

Extract the public key:

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

Encrypt a small secret with the public key:

openssl pkeyutl -encrypt \
  -pubin -inkey public.pem \
  -pkeyopt rsa_padding_mode:oaep \
  -in secret.txt \
  -out secret.txt.enc

Decrypt with the private key:

openssl pkeyutl -decrypt \
  -inkey private.pem \
  -pkeyopt rsa_padding_mode:oaep \
  -in secret.txt.enc \
  -out secret.txt

Do not use RSA to encrypt large files directly. It is not built for that. Use it to encrypt a random file key, then use that file key with a symmetric cipher. This hybrid pattern is how many serious systems work.

The hybrid model is what you usually want

Most secure tools combine both methods. This is not a compromise. It is the normal design.

  1. The tool creates a random symmetric key.
  2. It encrypts the file with that fast symmetric key.
  3. It encrypts the symmetric key with the recipient’s public key.
  4. The recipient uses the private key to unlock the symmetric key.
  5. The symmetric key decrypts the file.

age handles this cleanly with recipients. First, create a key pair:

age-keygen -o key.txt

The file will contain a public recipient line and a private identity. Encrypt for that recipient:

age -r age1examplepublickeyhere -o archive.tar.age archive.tar

Decrypt using the private identity file:

age -d -i key.txt -o archive.tar archive.tar.age

This is a strong fit for sending files to a colleague, storing CI secrets, or keeping sensitive exports in object storage. The recipient does not need your password. You do not need their private key. That separation is the whole point.

Other security tools and where they fit

  • GnuPG: Good for OpenPGP email and older workflows. Powerful, but the command set can feel heavy.
  • SSH: Best known for login, but it also relies on asymmetric keys for identity.
  • WireGuard: Uses public keys for peer identity and symmetric crypto for traffic protection.
  • LUKS: A standard choice for Linux disk encryption.
  • BitLocker and FileVault: Built-in disk encryption for Windows and macOS.

Which one should you choose?

Use symmetric encryption when you control both ends and need speed. Use asymmetric encryption when you need to send encrypted data to another person or system without sharing a password first.

For everyday file encryption, age is often the best starting point. For certificates, low-level testing, and infrastructure work, OpenSSL remains useful. For disks, use the operating system’s native encryption. The safest choice is the one that protects the key well, not the one with the most impressive command line.