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.

Installing aespipe.

#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

or

$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.

j^WE\<97>.^B<B2>^C'wq<F8>^]<F9>9<F0><90><CB>^G<EA>p<A6><F3>m`^F*\<BA>^BJ<D5>E'^K<82>T^PK"^O$l^L٥<D5>9(T8<8D><DA><FD><A2><FB>NE^V
<E0>C<EE><AD><DA>V<E6>7^Y3V<8D>.=qא<B0>u:^<B6>W˖4np<AF>.=<EC>b<CA>}<[<FC>s<8C><86><A5>^A<E1><FC><F3>DŽ<CC><F3><CB>,<EA><DB>j}<87>
<DC>Oj6<D4>o<A4><D2>}<B6>38X<B2><F7>^z<AE>^@<B9>`<F2><B5><E1><A6><U+A06F2><96><B4><A8>=<C5>0,<94>X6<9B>^T^AO<E9><83>}<EB><96>Š^GX
^UrT`<ED>^Ss1<BD><A3>^?<C5><C4><E6><DA>z㔽<ED>^_<A9>^\^M<ED>*<B0>S<C1><A4><E3>c<97><FC>a<98><B6><DE>^^<D2>tON<A5><91>._<F7><8C>
<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>
<EA><EF><FC><C0><FC>3<C5>ESCLy<A7>JZ<E6><<C2>2][h<99>H^EѬ^?У^C<D1>_<C9>ۮ<8B>b<EE>^T<F0>^H%#<AE>S<DA>;<82><85>R<BB><D5>^\J<98><B1>
<C0><DD>$2<E9><F8><91>Yb<B5>^V><D3>|it<D7><DC><E5>^@^Dv>^B<A3>
<D9><DF><EE><CB>d^D^Ks^<CE>H<BB><BF><F8>Y<93><9C><A9><97><D5><E2><9D><E1><89>^M<99>^\b9<F4><A5>^^^V<AB>ok<BC><A0><CC>D<C2>j<AA>3

To decrypt it.

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

You can also encrypt and decrypt tar file with the 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 -

For more information.

$man aespipe