Encrypting with aespipe

Hi folks! It has been long time that I did not post anything on my blog.  Actually, I set sail for new adventure, new job– I will move to Wrocław, Poland. So I have many things to do. Anyway. In this post, I write about encrypting a file in Linux. Actually, there are many command line tools for this. In this post I will write about aespipe. Aespipe is a command line tool that can be used to create and restore tar or cpio archives. aespipe encrypts and decrypts block of data.

yum install epel-release -y
yum install aespipe -y

Creating Secret Key

Next thing is creating a secret key to encrypt our secret message. Actually, there is many ways to it on Linux.  Just pick one of below to create a secret key. Actually, Here my secret key is just a 20 characters you can increase or decrease its size.

$tr -dc [:alnum:] < /dev/urandom | head -c 20 > secret.key


$openssl rand -hex 20 > secret.key

Encrypt your file or your block disk. You can encrypt your secret.txt file.

$cat secret.txt

“If you're going to try, go all the way. Otherwise, don't even start. This could mean losing girlfriends, wives, relatives and maybe even your mind. It could mean not eating for three or four days. It could mean freezing on a park bench. It could mean jail. It could mean derision. It could mean mockery--isolation. Isolation is the gift. All the others are a test of your endurance, of how much you really want to do it. And, you'll do it, despite rejection and the worst odds. And it will be better than anything else you can imagine. If you're going to try, go all the way. There is no other feeling like that. You will be alone with the gods, and the nights will flame with fire. You will ride life straight to perfect laughter. It's the only good fight there is.”
$aespipe -e AES256 -C128 -P secret.key < secret.txt > encrypted.msg
Output of encrypted.msg file with **less** command.```
<FE><AC>3<93>.^DPESC\*<B7><C0><AB><FB>^O<D9>^@<FE><FB>^X<91><86>3<E9>\[W<95>t<F7><A7>3<B2>\[<90><AE>ف<EE>kU<BC>^D<C4><E2>  ʟ<AC><F3>


aespipe -d -e AES256 -C128 -P secret.key < encrypted.msg > message.txt

You can also encrypt and decrypt tar file same way.

Encrypt tar file

tar cvf  - secret.txt | aespipe -e AES256 -C128 -P secret.key  > secret.tar.sec

Decrypt tar file

aespipe -d -e AES256 -C128 -P secret.key < secret.tar.sec | tar xvf -

Leave a Reply

Your email address will not be published. Required fields are marked *

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