Home Encryption / Decryption Cryptr – A Simple CLI Utility To Encrypt And Decrypt Files

Cryptr – A Simple CLI Utility To Encrypt And Decrypt Files

By sk
Published: Last Updated on 3.1K views

Looking for a quick, easy, and secure method to protect your files? Well, there is a simple shell utility called "Cryptr" that helps you to encrypt and decrypt files. All from command line, and you don't need to be a security ninja or Linux expert to learn how to secure your data. Cryptr uses OpenSSL AES-256 cipher block chaining method to encrypt files. It is free to use and is licensed under the Apache License, Version 2.0.

Encrypt And Decrypt Files Using Cryptr

Installation is not a big deal. Git clone Cryptr repository using command:

$ git clone https://github.com/nodesocket/cryptr.git

This command will clone the contents of Cryptr repository in a folder called cryptr in your current working directory.

Then link the cryptr.bash file to your bin folder using command:

$ sudo ln -s "$PWD"/cryptr/cryptr.bash /usr/local/bin/cryptr

That's it. It's time to see some usage examples.

Let us encrypt a file called "test.txt". To do so, run the following command from your Terminal. Cryptr will ask you to enter the password to the file twice.

$ cryptr encrypt test.txt 
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:

The above command will encrypt the given file (I.e test.txt) using AES-256-CBC encryption method and save it with an extension .aes. You can use "ls" command to verify if the file is really encrypted or not.

View Encrypted File

View Encrypted File

If there is .aes extension at the end of the file name, it means that the file has been encrypted.

To decrypt an encrypted file, use the following command. Enter the correct password and voila!

$ cryptr decrypt test.txt.aes 
enter aes-256-cbc decryption password:

You can also define the password to use when encrypting a file using the CRYPTR_PASSWORD environment variable like below.

$ CRYPTR_PASSWORD=BC1rO7K7SspYcLChMr28M cryptr encrypt test.txt 
Using environment variable CRYPTR_PASSWORD for the password

Here, BC1rO7K7SspYcLChMr28M is the password to the file.

Similarly, to decrypt an encrypted file, use:

$ CRYPTR_PASSWORD=BC1rO7K7SspYcLChMr28M cryptr decrypt test.txt.aes
Using environment variable CRYPTR_PASSWORD for the password

This can be helpful in scripts and batch operations.

To view the help, run:

$ cryptr help
Usage: cryptr command <command-specific-options>

encrypt <file> Encrypt file
 decrypt <file.aes> Decrypt encrypted file
 help Displays help
 version Displays the current version

If you're looking for a simple utility that just works out of the box without much hassle, give Cryptr a try.

Resource:

You May Also Like

4 comments

IJK November 14, 2017 - 8:25 am

Come on, guys. This utility is a very trivial exercise in beginning shell programming.

Reply
John Aerdn December 10, 2017 - 11:39 pm

Not everyone is a “guru” like you my dear Sir.

Reply
John Aerdn December 10, 2017 - 11:43 pm

Great script and flows well. However, where I think is falls short is that the input file remains in clear text. So perhaps adding a function using the “wipe” utility (if available) and then when decrypting, restore the original file. So basically always remove the input file after encrypting then restore when decrypting.

Reply
John Aerdn December 11, 2017 - 12:10 am

Great script and flows well. However, where I think is falls short is that the input file remains in clear text. So perhaps adding a function using the “wipe” utility (if available) and then when decrypting, restore the original file. So basically always remove the input file after encrypting then restore when decrypting.

Maybe something like this: wipe -ceifr “$_file” & wipe -ceifr *.aes

Thank you for sharing!!!

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More