Sign in to follow this  
Followers 0
TomCat

Big problem or bug with AES_Optimized.au3

7 posts in this topic

#1 ·  Posted (edited)

Hi i have a big problem using AES_Optimized.au3

I use this file to endcrypt the text in a fiel:

#include <AES_Optimized.au3>
$key = "000102030405060708090a0b0c0d0e0f"
$file = FileOpen("testtoencypt.txt", 0)
$file1 = FileRead($file)
$Cipher = AES_Cipher($key, $file1 )
$file1 = FileOpen("cryptext", 2)
FileWrite($file1, $Cipher)
FileClose($file1)

And this file to decrypt:

#include <AES_Optimized.au3>
$key = "000102030405060708090a0b0c0d0e0f"
$file = FileOpen("cryptext", 0)
$decrypt = FileRead($file)
$decrypt1 = AES_InvCipher($key, $decrypt)
FileClose($file)
$file1 = FileOpen("decryptext.txt", 2)
FileWrite($file1, $decrypt1)
FileClose($file1)

If if write this to the testtoencypt.txt file :

12345678

12345678

12345678

12345678

12345678

12345678

it works and i can decrypt it again.

But if i write this in the testtoencypt.txt:

12345678

12345678

12345678

12345678

12345678

12345678

12345678

it doesnt work. I cant decrypt it again the decryptext.txt stays empty :)

I use AutoIt v3, 2, 4, 9

Some ideas what to do to fix it ?

Edited by TomCat

Share this post


Link to post
Share on other sites



:P Confusing ...

If if write this to the testtoencypt.txt file :

12345678

12345678

But if i write this in the testtoencypt.txt:

12345678

12345678

same filename, same content ... :) what do you really want to say?


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

The difference is the number of items in the file. Count the lines, and you'll see.

I've tested it a bit, and it has me sort of stumped. Add this line after you create the cryptext file, and you'll see partly why:

MsgBox(0,"Info",AES_InvCipher($key, $Cipher))

This shows the decryption working just as it should, so there's some error in writing to/reading back from a file. I'm still playing with it, and I'll see if I can help, seeing as I released the AES script so I feel responsible for it.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I found one way to get it work but its not what i want to have :P

If I write testtoencypt.txt it in this format:

12345678;12345678;12345678;12345678;12345678;12345678;12345678;12345678;12345678;12345678

it works. The problem seams to be the linebreaks.

Its realy confusing for me :)

Edited by TomCat

Share this post


Link to post
Share on other sites

Change your encryption program to this:

#include <AES_Optimized.au3>
$key = "000102030405060708090a0b0c0d0e0f"
$file = FileOpen("testtoencypt.txt", 0)
$file1 = FileRead($file)
$Cipher = AES_Cipher($key, $file1 )
$file1 = FileOpen("cryptext", 18)
FileWrite($file1, $Cipher)
FileClose($file1)

If you can't see the difference, it's the final FileOpen. In Debugging, I found that part of your input text was resulting in a 00 being created in the middle of the encrypted text. That usually signals the end of the line, so the FileWrite stopped writting the info to the file. Using 18 instead of 2 puts FileOpen into Binary Write mode, which will write 00 (aka NULL) characters to a file without a problem.

As a side note, that is a one in a million chance problem, as not to many encryption operations will produce a NULL character. If you had changed but one Number in the Key, you probably wouldn't have had this problem.

I'm glad to see some people actually using these UDFs of mine. Makes me glad I put them up here.

Share this post


Link to post
Share on other sites

TNX :) Seams to work but its courious if i write some thinks in testtoencypt.txt it works some others it works not

Then it works with some keys better then with others....its realy confusing....

Share this post


Link to post
Share on other sites

Well, the only explanation I can give you is that little changes make big differences. It all has to do with that fact. A change in just one number in the Key can have a huge difference in the results of the encryption, and, honestly, that's a good thing. Otherwise, it would be easy for people to crack and retrieve your hidden content without your knowledge. Little changes in the testtoencypt.txt files also cause big changes in the resulting encryption. Writing to the file the way I showed should solve most problems you were having. If not, post back and I'll try to help out some more.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0