Jump to content

BASh AES encryption for string of text


Recommended Posts

I am trying to figure out how to encrypt a string of text in BASh by inputting plain text (in English) and a key string. There are plenty of ways and instructions out there on how to encrypt and decrypt files from the command line but I do not want to use files. I know there are more elgant solutions for AES encryption of text but I have found that using GUI software is much too slow and involved for my needs most of the time. So what is the secret to inputting a couple sentences, inputting a key string, and getting the AES encrypted version of the text in the print?

I can't believe I am not able to find any instructions for this after 30 minutes of searching google! It seems to me like a lot of people would want to know how to do this.

Link to comment
Share on other sites

Two programs come to my mind:

  • aespipe
  • aesutil

Demo of aesutil:

$ /opt/local/bin/aes -e -b -s "Encrypted me" -p password
hq6kK1M5d5x45DCF7pmELXUzW3ARHV9A/zJcTw==
$ /opt/local/bin/aes -d -b -s "hq6kK1M5d5x45DCF7pmELXUzW3ARHV9A/zJcTw==" -p password
Encrypted me
$ 

flags:

-e encrypt

-d decrypt

-b base64 encode/decode (otherwise you get non-printable chars)

-s this_string (blank for stdin)

-p the encryption/decryption password

Edited by midnitesnake
Link to comment
Share on other sites

Two programs come to my mind:

  • aespipe
  • aesutil

Demo of aesutil:

$ /opt/local/bin/aes -e -b -s "Encrypted me" -p password
hq6kK1M5d5x45DCF7pmELXUzW3ARHV9A/zJcTw==
$ /opt/local/bin/aes -d -b -s "hq6kK1M5d5x45DCF7pmELXUzW3ARHV9A/zJcTw==" -p password
Encrypted me
$ 

I checked out aespipe but it doesn't seem to support encryption of text directly input into the command line but, rather, only supports encrypting files and some other options. I haven't heard of aesutil. That seems to be much closer to what I need. I will try that out, if I can understand the man pages that is. I'm still not very efficient with the CLI but hopefully I can figure it out and make it work.

Link to comment
Share on other sites

  • 3 weeks later...

I know they have things built into a lot of systems like md5sum, so there might be an already built tool for what you want to do the same thing with other cryptography or cat a file to a text document with password, into a crypted file etc and vice versa.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...