AES Crypt for encrypting strings

Discussion related to AES Crypt, the file encryption software for Windows, Linux, Mac, and Java.
Post Reply
User avatar
paulej
Posts: 595
Joined: Sun Aug 23, 2009 7:32 pm
Location: Research Triangle Park, NC, USA
Contact:

AES Crypt for encrypting strings

Post by paulej »

How many would like to be able to call encrypt_string() to encrypt a string in memory using AES? I took the Linux AES Crypt code and create string encryption functions that accept a password and plaintext string, then returning an encrypted string in the format of AES File Format Version 0. Version 0 is very suitable for encrypting small bits of data like strings. It can make strings longer (as much as 68 octets more) to accommodate the header, initialization vector, and to pad the cipher block. But, the cool thing is that the strings can be decrypted using AES Crypt.

Anyone interesting such a tool? If so, I'll clean up the code and post it.
rjk
Posts: 3
Joined: Fri Mar 09, 2012 9:15 am

Re: AES Crypt for encrypting strings

Post by rjk »

Yes please, that would be useful.
User avatar
paulej
Posts: 595
Joined: Sun Aug 23, 2009 7:32 pm
Location: Research Triangle Park, NC, USA
Contact:

Re: AES Crypt for encrypting strings

Post by paulej »

OK, I have posted it to the AES Crypt site. I've tested the code on Linux, but I have not tested the code on Windows. If you're doing development in Windows, please give it a basic sanity check. The only Windows-specific code is the use of the random number generator and I borrowed that code from the current AES Crypt for Windows, then modified for this particular application. So, it should work, but needs testing.

You can grab a copy from the download page:
https://www.aescrypt.com/download/

If somebody would like to write a simple program to test the functions on Windows, that would be great.

Note that to retain compatibility with AES Crypt, passwords must be in UTF-16 format. That said, there is nothing preventing one from using ASCII, UTF-8, or any other encoding. The only thing that is important is that the same character encoding is used when decrypting. I chose to use UTF-16 years ago since that was native to Windows. For good or bad, that's the way it is :-)

Let me know how it works for you.

Paul
Cass
Posts: 1
Joined: Thu Aug 16, 2012 6:32 am

Re: AES Crypt for encrypting strings

Post by Cass »

Feels like I arrived late to this topic, but I found this thread while searching for a utility to do just that - encrypting strings using AES, preferably without involving messy (and performance sapping) temp files.

Essentially my goal is to find a routine I can pass a variable to (or even supply the string to a standalone executable, in the form of a command line argument) and get back something suitable for storing in another variable, so this may be exactly what I was after.

To Paul's original question, yes, there's at least two of us now with our hands in the air :D I'm not sure if the .tgz package mentioned above contains something suited to a windows implementation - taking a close look now.

Two thumbs up for creating AEScrypt by the way, not only for its functionality but also the non-restrictive license terms. (I was also pleased to hear it receive positive comment on the 'Security Now' podcast recently).
User avatar
paulej
Posts: 595
Joined: Sun Aug 23, 2009 7:32 pm
Location: Research Triangle Park, NC, USA
Contact:

Re: AES Crypt for encrypting strings

Post by paulej »

Cass wrote:I'm not sure if the .tgz package mentioned above contains something suited to a windows implementation
It has not been fully tested, but it is written so that it will compile on both Windows, Linux, etc. You'll see #ifdef statements in the code to conditionally compile in the required Windows libraries.

Note that this version of the code only produces encrypted strings using "file format 0". This the simplest of the formats and was selected because it will produce the most compact encoding. The resulting output can be decrypted by AES Crypt (the application), but this code will not decrypt data encoded the newer file formats.

It might be useful to at least modify the code to handle all formats as input formats, but I like the fact it produces the more compact encoding. File Format 0 is secure, but lacks the "bells and whistles" of the newer formats, including clear text metadata in the header and faster detection of incorrect passwords. However, neither is really that important if the application just wants to encrypt a string in memory, I think.

By the way, if you (or others) work with this code a bit and see that it's pretty stable, I'll put up a page on the aescrypt.com site dedicated to it. I can definitely see the utility in having this small library, but I don't personally have the need to encrypt strings, so I've only done very basic testing.
GrogHills
Posts: 1
Joined: Fri Jul 25, 2014 11:42 pm

Re: AES Crypt for encrypting strings

Post by GrogHills »

Greetings. This is exactly what I'm looking for but that link is no longer available.

Our goal is to generate a LF delimited list of strings from a text file, then generate a LF delimited text file with the strings encrypted in it. This is a slightly different use case, but I think this code should help us get there. Is it still available? Or is there something else that could help us achieve this requirement?

Thank you so much!
User avatar
paulej
Posts: 595
Joined: Sun Aug 23, 2009 7:32 pm
Location: Research Triangle Park, NC, USA
Contact:

Re: AES Crypt for encrypting strings

Post by paulej »

Yes, it is still available. I had moved the file to a more permanent home, but obviously didn't think about links to the old location in the forums. You can find a link on the download page:

https://www.aescrypt.com/download/

It's called "C Routines for String Encryption" on the page, but the package is called "AESStringCrypt".
dellmerca
Posts: 1
Joined: Mon Jan 04, 2016 5:30 am
Contact:

Re: AES Crypt for encrypting strings

Post by dellmerca »

Hope this will help you....string encryption

Dell
JaysonBourne
Posts: 1
Joined: Fri Feb 15, 2019 2:10 am

Re: AES Crypt for encrypting strings

Post by JaysonBourne »

Hi @paulej

I recently downloaded the 'C string encryption' files mentioned in this thread and ran into a problem on Windows 10. I did not bother to create a lib and just included the four *.c files in my current compilation string (lazy, but it should work).

GCC 64Bit Compiler immediately halted all my fun complaining about 'langinfo.h' which as far as I know is a Linux header. It is requested by 'password.c' which in turn is requested by 'AESStringCrypt.c' originally. Is this only for Linux users, or should I download the header and include it? Better yet... Is there a way to exclude it completely?

Kind Regards

Jayson
User avatar
paulej
Posts: 595
Joined: Sun Aug 23, 2009 7:32 pm
Location: Research Triangle Park, NC, USA
Contact:

Re: AES Crypt for encrypting strings

Post by paulej »

Jayson,

I assume that's just to support character conversation. I can't recall, but you could find out quickly if you comment it out.

I took the code version and created a DLL out of it on Windows a few months ago. I used since certain if VC++, but I can't recall if I had to make those kinds of changes. I remember it was pretty easy, though.

Paul
Post Reply