openssl enc vs gpg: I Benchmarked AES256 Encryption on Both

– min read

If you ever need to encrypt 256 MB of file data on a server, which tool finishes first? OpenSSL and GnuPG are installed on every Linux distribution I touch. I benchmarked both doing AES256 symmetric encryption and decryption on 256 MB random data.


What you need:

  1. A Linux machine with openssl and gpg installed (both ship with every distro)
  2. /usr/bin/time (from time package, also default on most)
  3. Enough disk space for a 256 MB test file


Method. I generated 256 MB of random data from /dev/urandom, then ran each tool on encrypt and decrypt with /usr/bin/time -v for precise wall-clock and resident memory measurement. Both tools used AES256 (OpenSSL: -aes-256-cbc -pbkdf2 -iter 100000, GPG: --symmetric --cipher-algo AES256 -z 0 to disable compression). I verified integrity by comparing SHA-256 checksums of the original and decrypted files. All data is synthetic random data — reproducible results.


OpenSSL vs GPG encryption benchmark pipeline diagram
OpenSSL enc vs GPG symmetric encryption benchmark pipeline — Authors own diagram


Commands I ran:

# Generate 256 MB random dataset
dd if=/dev/urandom of=data.raw bs=64M count=4 iflag=fullblock

# OpenSSL AES-256-CBC encrypt/decrypt
openssl enc -aes-256-cbc -pbkdf2 -iter 100000 -salt \
  -pass pass:benchpass -in data.raw -out data.enc
openssl enc -d -aes-256-cbc -pbkdf2 -iter 100000 \
  -pass pass:benchpass -in data.enc -out data_dec.raw

# GPG symmetric AES256 encrypt/decrypt (no compression)
gpg --batch --yes --passphrase benchpass \
  --symmetric --cipher-algo AES256 -z 0 \
  --output data.gpg data.raw
gpg --batch --yes --passphrase benchpass \
  --decrypt --output data_dec.raw data.gpg


Output:

openssl encrypt...
  0.80s user=0.48s RSS=8036KB out=268435488
openssl decrypt...
  0.61s user=0.29s
gpg encrypt...
  1.31s user=0.89s RSS=6260KB out=268435537
gpg decrypt...
  0.88s user=0.69s
Integrity: openssl ok=True, gpg ok=True


Comparison:

MetricOpenSSL encGPG
Encrypt time0.80 s1.31 s
Encrypt throughput320 MB/s195 MB/s
Decrypt time0.61 s0.88 s
Decrypt throughput420 MB/s291 MB/s
Max RSS~8 MB~6 MB
Output size (256 MB input)268,435,488 B268,435,537 B
Integrity (SHA-256)MatchMatch
Key derivationPBKDF2 (100k iters)Built-in S2K


Bar chart comparing OpenSSL and GPG throughput in MB/s for AES256 encrypt and decrypt
Throughput comparison bar chart – OpenSSL enc vs GPG AES256 – Authors own diagram


Verdict. OpenSSL enc is 1.6x faster on encrypt and 1.4x faster on decrypt on this 2 vCPU machine. It also uses marginally more RSS (~8 MB vs ~6 MB). GPG wins on ergonomics: its output format is self-describing (OpenPGP), key derivation is handled transparently, and the tool is designed for encrypted file exchange, not just raw symmetric ciphers. If you encrypt backup files for your own offsite storage, openssl enc with PBKDF2 is faster. If you share encrypted files with others or need a standard format, use GPG.


If you work with backup pipelines, you might also find rsync vs rclone: I Benchmarked Both and gzip vs zstd: I Benchmarked Both useful. I also wrote a Python script to verify backup archives that complements these encryption tools nicely.


I used synthetic 256 MB random data for reproducibility. Your mileage will vary by CPU, AES-NI support, and dataset size. Run your own benchmark before choosing one for a production pipeline.

Mohamad ZulfahmyCybersecurity · OffSec · Entrepreneur
About me ↗
ON THIS PAGE
On this page