Encryption & Decryption

openssl-enc

Encrypt file with AES-256-CTR, base64 encoding, PBKDF2:

$ openssl enc -aes-256-ctr -pbkdf2 -a -in <file>

Decrypt file encrypted with options above:

$ openssl enc -d -aes-256-ctr -pbkdf2 -a -in <file>

SSL

openssl-x509

Print certificate of website in text form:

$ echo "QUIT" | openssl s_client -connect www.ekzy.is:443 2>/dev/null | openssl x509 -text -noout

Common certificate printing options

Use these instead of -text:

  • -enddate: certificate dates
  • -ext=subjectAltName: print Subject Alternative Name

CSPRNG

openssl-rand

32 random bytes in hex or base64:

$ openssl rand -hex 32
$ openssl rand -base64 32