Science and technology

Encrypt and decrypt information with a passphrase on Linux

Encryption and safety for shielding information and delicate paperwork have lengthy been a priority for customers. Even as increasingly of our information is housed on web sites and cloud companies, protected by consumer accounts with ever-more safe and difficult passwords, there’s nonetheless nice worth in with the ability to retailer delicate information on our personal filesystems, particularly once we can encrypt that information shortly and simply.

Age means that you can do that. It is a small, easy-to-use instrument that means that you can encrypt a file with a single passphrase and decrypt it as required.

Install age

Age is out there to install from most Linux repositories.

To set up it on Fedora:

$ sudo dnf set up age -y

On macOS, use MacPorts or Homebrew. On Windows, use Chocolatey.

Encrypting and decrypting information with age

Age can encrypt and decrypt information with both a public key or a passphrase set by the consumer.

Using age with a public key

First, generate a public key and write the output to a key.txt file:

$ age-keygen -o key.txt
Public key: age16frc22wz6z206hslrjzuv2tnsuw32rk80pnrku07fh7hrmxhudawase896m9

Encrypt with a public key

To encrypt a file together with your public key:

$ contact mypasswds.txt | age -r ageage16frc22wz6z206hslrjzuv2tnsuw32rk80pnrku07fh7hrmxhudawase896m9 > mypass.tar.gz.age

In this instance, the file mypasswds.txt is encrypted with the general public key I generated and put inside an encrypted file referred to as mypass.tar.gz.age.

Decrypt with a public key

To decrypt the knowledge you’ve got protected, use the age command and the --decrypt choice:

$ age --decrypt -i key.txt -o mypass.tar.gz mypass.tar.gz.age

In this instance, age makes use of the important thing saved in key.textual content and decrypts the file I created within the earlier step.

Encrypt with a passphrase

Encrypting a file with no public key is named symmetrical encryption. It permits a consumer to set the passphrase to encrypt and decrypt a file. To accomplish that:

$ age --passphrase --output mypasswd-encrypted.txt mypasswd.txt
Enter passphrase (depart empty to autogenerate a safe one):  
Confirm passphrase:

In this instance, age prompts you for a passphrase, which it makes use of to encrypt the enter file mypasswd.txt and render the file mypasswd-encrypted.txt in return.

Decrypt with a passphrase

To decrypt a file encrypted with a passphrase, use the age command with the --decrypt choice:

$ age --decrypt --output passwd-decrypt.txt mypasswd-encrypted.txt 

In this instance, age prompts you for the passphrase, then decrypts the contents of the mypasswd-encrypted.txt file into passwd-decrypt.txt, so long as you present the passphrase that matches the one set throughout encryption.

Don’t lose your keys

Whether you are utilizing passphrase encryption or public-key encryption, you should not lose the credentials to your encrypted information. By design, a file encrypted with age can’t be decrypted with out the important thing used to encrypt it. So again up your public key, and bear in mind these passphrases!

Easy encryption ultimately

Age is a very sturdy instrument. I prefer to encrypt my delicate information, particularly tax information and different archival information, right into a .tz file for later entry. Age is user-friendly and makes it very simple to get began with encryption on the go.

Most Popular

breakingExpress.com features the latest multimedia technologies, from live video streaming to audio packages to searchable archives of news features and background information. The site is updated continuously throughout the day.

Copyright © 2017 Breaking Express, Green Media Corporation

To Top