Home > Tech, Uncategorized > Useful OpenSSL Commands

Useful OpenSSL Commands

A list shamelessly copied from: http://aerokid240.blogspot.com/2010/03/getting-started-with-openssl.html

#  According to its manpage, it is a cryptography toolkit implementing the Secure Sockets Layer (SSL v2/v3) and
#  Transport Layer Security network protocols and related cryptography standards required by them. It is indeed
#  a command line tool and allows you to create RSA and DSA keys, x.509 certificates, calculation of message
#  digests, encryption and decryption of files with optional ciphers, etc. As there are so many ways to use this
#  tool, i will show some of its basic usages that one may find useful.

# for command switches
openssl -h

# Documentation of the tool
man openssl

# list standard commands. Doesn't say what they do so you are better off using "man openssl"
openssl list-standard-commands

# list different symmetric ciphers you can use for encryption
openssl list-cipher-commands

# lists different hashing algorithms you can use for data integrity checking
openssl list-message-digest-commands

# creates the md5 hash for the string password
echo "password" | openssl md5

# does the same thing as previous example
echo "password" | openssl enc -md5

# encrypts the file "myfile.txt" using the blowfish cipher 'bf' to a new file 'myfile.txt.enc'. You can now delete the old file
openssl bf -in myfile.txt -out myfile.txt.enc

# encrypts the file "myfile.txt" using the blowfish cipher 'bf' to a new file 'myfile.txt.enc'. Equivalent to the above command.
openssl enc -bf -in myfile.txt -out myfile.txt.enc

# decrypts the file "myfile.txt.enc" using the blowfish cipher 'bf' and outputs the decrypted file to a new file name 'myfile.txt'.
openssl enc -bf -d -in myfile.txt.enc -out myfile.txt

### Using Public Key Cryptography

# Generates private key
openssl genrsa -out private.key

# generates public key from the private key
openssl rsa -pubout -in private.key -out public.key

# encrypt a file with public key. Note that you are limited to small file sizes
openssl rsautl -encrypt -inkey public.key -pubin -in test.txt -out test.txt.pub

# decrypts the file with the private key
openssl rsautl -decrypt -inkey private.key -in test.txt.pub -out test.txt

Advertisements
Categories: Tech, Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s