$ echo "test file"> foo.txt
$ openssl dgst -md5 foo.txt
$ openssl dgst -sha1 foo.txt
To view the other message digests that can be used, look at the output of openssl list-message-digest-commands.
You can also use openssl to encrypt files. To view the list of available ciphers, use openssl list-cipher-commands. Once you’ve chosen a cipher to use, you can encrypt the file using the following commands:
$ openssl enc -aes-256-cbc -salt -in foo.txt -out foo.enc
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
$ file foo.enc
$ cat foo.enc
$ openssl enc -d -aes-256-cbc -in foo.enc
enter aes-256-cbc decryption password:
In the above example, the file foo.txt was encrypted using 256-bit AES in CBC mode, the encrypted copy being saved as the file foo.enc. Looking at the contents of the file provide gibberish. Decrypting the file is done using the -d option, however keep in mind that not only do you need to remember the password, you also need to know the cipher used.
I hope it will help You :)