Jump to content

AES_Optimized.au3


Recommended Posts

Hello,

Sorry for my language but i am french...

I would like to know if it's possible to create a variable (or other ?) which store an decripted file in memory (?) ?

For the moment i make like this :

#include <AES_Optimized.au3>

Func decrypt()
$file = FileOpen("test.ini", 0)
$key1 = "12345678912345678912345678912345"
$key = _StringToHex($key1)
$decrypt = FileRead($file)
$decrypt1 = AES_InvCipher($key, $decrypt)
FileClose($file)

$file1 = FileOpen("test.ini", 2)
FileWrite($file1, $decrypt1)
FileClose($file1)
EndFunc

Func encrypt()
$file = FileOpen("test.ini", 0)
$key1 = "12345678912345678912345678912345"
$key = _StringToHex($key1)
$Encrypt = FileRead($file)
$encrypt1 =  AES_Cipher($key, $Encrypt)
FileClose($file)

$file1 = FileOpen("test.ini", 2)
FileWrite($file1, $encrypt1)
FileClose($file1)
EndFunc

And i do that for decrypting-encrypting test.ini inside the code :

; ...code before

decrypt()
IniWrite("test.ini", "PASS", "Mot de passe", $pass)
encrypt()

;... code after

and as that each time test.ini is called...

That work but this way solicit le processor... :whistle:

THANKS

Link to comment
Share on other sites

I would like to know if it's possible to create a variable (or other ?) which store an decripted file in memory (?) ?

For the moment i make like this :

and as that each time test.ini is called...

That work but this way solicit le processor... :lmao:

I'm not sure I understand the question. You are reading the file into a variable, and performing the encrypt/decrypt on the variables (in memory). So you seem to already have what you are asking for.

Perhaps you only mean you want to do the IniWrite() on the file image in memory without saving it to a file? In that case, code your own function to perform the string processing that will make the same change IniWrite() would. For example, to find the begining of the section:

$SecStart = StringInStr($decrypt1, "[" & $Section & "]")oÝ÷ Øôz··öÆzj(|âZ¸­xÌzl!Èp¢¹,¶¬jg°âZ¸­y»­Âä²Ú²Úâ§é¨¯+âqê'¶WºÚ"µÍÚ[ÛYH    Ø^K]LÉÝÂÌÍÒ[Q[HH ][ÝÕÝ[I][ÝÂÌÍÜÒ[Q]HH[TXY
    ÌÍÒ[Q[JBÒ[UÜ]R[Y[J ÌÍÜÒ[Q]K    ][ÝÑ[Ú   ][ÝË  ][ÝÍI][ÝË   ][ÝÐÚ[I][ÝÊBÙÐÞ
    ][ÝÔÝ[É][ÝË   ÌÍÜÒ[Q]JB[ÈÒ[UÜ]R[Y[JTY  ÌÍÜÑ[Q]K    ÌÍÜÔÙXÝ[Û    ÌÍÜÒÙ^K    ÌÍÜÕ[YJBSØØ[  ÌÍØ]Ü]  ÌÍÚTÝ   ÌÍÚQ[    ÌÍÚS]ÒÙ^HHBRYÝ[Ò[Ý  ÌÍÜÑ[Q]K    ][ÝÖÉ][ÝÈ  [È ÌÍÜÔÙXÝ[Û    [È ][Ý×I][ÝÊH[BNÈ[ÙÈ^Ý[ÈÙXÝ[ÛBIÌÍØ]Ü]HÝ[ÔÜ]
    ÌÍÜÑ[Q]KÔJBBNÈ[ÝÙÙXÝ[ÛBIÌÍÚTÝHÐ^TÙXÚ
    ÌÍØ]Ü]  ][ÝÖÉ][ÝÈ  [È ÌÍÜÔÙXÝ[Û    [È ][Ý×I][ÝËJBBRYÜ[]Ù]ÜKÜ
BBBBNÈYH[BBRY  ÌÍÚTÝH  ÌÍØ]Ü]ÌH[BBNÈYÈ[YÙXÝ[ÛÝÈ][ÙÝ[È
^JBBBWÐ^PY
    ÌÍØ]Ü]  ÌÍÜÒÙ^H    [È ][ÝÏI][ÝÈ   [È ÌÍÜÕ[YJBBQ[ÙBBBNÈ[^ÙXÝ[ÛÝ
Y[JBBBQÜ   ÌÍÚQ[H   ÌÍÚTÝ
ÈHÈ   ÌÍØ]Ü]ÌBBBBRYÝ[ÓY
    ÌÍØ]Ü]ÉÌÍÚQ[KJHH    ][ÝÖÉ][ÝÈ[^]ÛÜBBS^BBBBBNÈÝÜÈ]H]ÙY[ÙXÝ[ÛÂBBRY    ÌÍÚQ[    ÝÈ    ÌÍÚTÝ
ÈH[    ÌÍÚQ[OHBBBBBBNÈÝÜÙ^H^ÝÂBBQÜ   ÌÍÚRÙ^HH    ÌÍÚTÝ
ÈHÈ   ÌÍÚQ[BBBRYÝ[ÓY
    ÌÍØ]Ü]ÉÌÍÚRÙ^WKÝ[Ó[  ÌÍÜÒÙ^JH
ÈJHH   ÌÍÜÒÙ^H    [È ][ÝÏI][ÝÈ[BBBBIÌÍÚS]ÒÙ^HH  ÌÍÚRÙ^BBBBBQ^]ÛÜBBBQ[YBBS^BBBBBNÈY]Ü[ÙHÙ^BBBRY    ÌÍÚS]ÒÙ^H[BBBNÈY]^Ý[ÈÙ^BBBBIÌÍØ]Ü]ÉÌÍÚS]ÒÙ^WHH   ÌÍÜÒÙ^H    [È ][ÝÏI][ÝÈ   [È ÌÍÜÕ[YBBBQ[ÙBBBBNÈ[Ù]ÈÙ^H[ÜÈ[È[È[ÙXÝ[Û
Y[JBBBBRY   ÌÍØ]Ü]ÉÌÍÚQ[HH  ][ÝÉ][ÝÈ[BBBBQÜ    ÌÍÚS]ÒÙ^HH ÌÍÚQ[È  ÌÍÚTÝ
ÈHÝHBBBBBBRY  ÌÍØ]Ü]ÉÌÍÚS]ÒÙ^WH ÉÝÈ  ][ÝÉ][ÝÈ[BBBBBBIÌÍÚS]ÒÙ^H
ÏHBBBBBBBQ^]ÛÜBBBBBQ[YBBBBS^BBBQ[ÙBBBBBIÌÍÚS]ÒÙ^HH ÌÍÚQ[BBBQ[YBBBWÐ^R[Ù
    ÌÍØ]Ü]  ÌÍÚS]ÒÙ^K  ÌÍÜÒÙ^H    [È ][ÝÏI][ÝÈ   [È ÌÍÜÕ[YJBBBQ[YBQ[YBIÌÍÜÑ[Q]HHÐ^UÔÝ[Ê ÌÍØ]Ü]ÔJBQ[ÙBBNÈY]ÈÙXÝ[ÛÈ[BIÌÍÜÑ[Q]H    [ÏHÔ  [È ][ÝÖÉ][ÝÈ  [È ÌÍÜÔÙXÝ[Û    [È ][Ý×I][ÝÈ   [ÈÔ   [È ÌÍÜÒÙ^H    [È ][ÝÏI][ÝÈ   [È ÌÍÜÕ[YH [ÈÔQ[YBT]B[[ÈÏOIÝ×Ò[UÜ]R[Y[

The Test.ini file used for the demo was:

[English]
1=One
2=Two
3=Three
4=Four

[French]
1=Un
2=Deux
3=Trois
4=Quatre

[Spanish]
1=Uno
2=Dos
3=Tres
4=cuatro

:whistle:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I'm not sure what you want.

Like the other poster said, you have what you want in memory, and can perform what you want to do on it,

You can also write it back with the FileWrite, as iniWrite will want keys I believe, so for encrypting, use IniRead to get the text from the INI file, and FileWrite, for decrypting, if you are storing it in another file, use FileRead, and IniWrite, just a reversal of the processes.

Thanks,

~~TheCreator~~Visit http://tysdomain.com for personal software and website solutions.

Link to comment
Share on other sites

Don't worry, me too i don't understand what i mean :whistle:

I've got a second question if i can : i try to use _StringEncrypt in complement so i do that :

decrypt() decrypt before

    $pass = IniReadSection("test.ini", "PASS"); read in decrypted mod and stay in memory
    
         encrypt(); encrypt after
    
    For $i = 1 To $pass[0][0]; defini the array
    $007 = _StringEncrypt(0,$pass[$i][1],"12345","3"); create a variable for the decrypted pass
    
    Next

Then this error appear :

==> Subscript used with non-Array variable.:

For $i = 1 To $pass[0][0]

For $i = 1 To $pass^ ERROR

But if i do that (without _StringEncrypt) :

decrypt()
$pass = IniReadSection("test.ini", "PASS")
            encrypt()
    
For $i = 1 To $pass[0][0]
    $007 = $pass[$i][1]
Next

That work. Have you got an idea why ?

Edited by FrenchTroll
Link to comment
Share on other sites

Can't tell without a running demo to see what's happening.

You are only posting non-running code fragments, and I don't see the problem from those. For example, if that was your actual code, the line:

decrypt() decrypt before
...would not execute because the semicolon is missing from the comment. But is that your real code? That error should be obvious from the SyntaxCheck (Ctrl-F5 in SciTE) if it's really in your code.

If that's not it, post a running script that demonstrates the problem. Make it as short as possible just to show the issue.

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I sought the error in the code and it's in the inifile that the error was... :lmao:

like that :

[English]

1=One

2=Two

3=Three

4=Four

that don't work

[English]

1 =One

2 =Two

3 =Three

4 =Four

with a space that work :whistle:

DUR DUR !

Thank you very much PsaltyDS for your help ;)

Link to comment
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
 Share

  • Recently Browsing   0 members

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