AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AES encryption: Translate Phyton code into AHK...

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
IsNull



Joined: 10 May 2007
Posts: 64
Location: .switzerland

PostPosted: Sat May 03, 2008 6:16 pm    Post subject: AES encryption: Translate Phyton code into AHK... Reply with quote

I've found a piece of python code, and tried to translate it into ahk. But in the decryption part, I've got some problems...

Here is the Python code:
Code:

        key = unhexlify('7B35193D966FC3182F6F84F3252239EB4C320D3600000000')
        cipher = AES.new(key, AES.MODE_ECB)
        iv = unhexlify('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')
        iv = cipher.encrypt(iv)
        aes_obj = AES.new(key, AES.MODE_CFB,iv)

        decStr = aes_obj.decrypt(encStr)


Ok, the key is hardcoded. The Function unhexlify() is the pendant to hex2str. (I've written this function):
Code:
;************hex2str*************
hex2str(hex){
stelle := 1   
Loop, parse, hex
{

   if (stelle = 1){
      tmphex_item := "0x" . a_loopfield
      stelle = 2
   }else if (stelle = 2){
      tmphex_item .= a_loopfield
      resultstr .= chr(tmphex_item)
      stelle = 1
   }
}
return, resultstr
}

OK. Easy.
But, then... I don't understand this AES encryption Sad

1. How can I implement the AES encryptin in AHK? I've only found file encryptions for AES in the forum.

2. For what stands the "iv" variable? It contains 32 F's...after the hex2str() procedure this are 16 "ÿ" - looks like a cypher-block Confused

Hope somebody can help Very Happy

Regards
IsNull
_________________
http://securityvision.ch
Back to top
View user's profile Send private message
greynite



Joined: 17 May 2008
Posts: 11

PostPosted: Mon May 19, 2008 5:16 pm    Post subject: Reply with quote

1. I haven't seen a native implementation of AES in AHK, which I'm a little surprised by since it's pretty simple to port. So your out of luck for an easy answer. An excellent guide for doing so can be found here. (It doesn't cover CFB mode though).

2. "iv" stands for Initialization Vector. It provides a bit of extra protection against rainbow table attacks. Think of it as fixed suppliment to the key.

Cheers,
Shawn
Back to top
View user's profile Send private message
heresy



Joined: 11 Mar 2008
Posts: 291

PostPosted: Mon May 19, 2008 5:22 pm    Post subject: Reply with quote

probably you're missing this
_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com
Back to top
View user's profile Send private message
greynite



Joined: 17 May 2008
Posts: 11

PostPosted: Mon May 19, 2008 11:05 pm    Post subject: Reply with quote

heresy wrote:
probably you're missing this

You're missing this...

IsNull wrote:
1. How can I implement the AES encryptin in AHK? I've only found file encryptions for AES in the forum.
Back to top
View user's profile Send private message
Guest






PostPosted: Mon May 19, 2008 11:57 pm    Post subject: Reply with quote

greynite wrote:
heresy wrote:
probably you're missing this

You're missing this...

IsNull wrote:
1. How can I implement the AES encryptin in AHK? I've only found file encryptions for AES in the forum.

No. You can encrypt any binary data invoking directly Crypt_AES().
Back to top
greynite



Joined: 17 May 2008
Posts: 11

PostPosted: Tue May 20, 2008 9:14 am    Post subject: Reply with quote

Anonymous wrote:

No. You can encrypt any binary data invoking directly Crypt_AES().

Interestingly enough, someone just posted an example over in that thread of doing just that.

Cheers,
Shawn
Back to top
View user's profile Send private message
IsNull



Joined: 10 May 2007
Posts: 64
Location: .switzerland

PostPosted: Sun Jul 20, 2008 12:23 pm    Post subject: Reply with quote

Hey you guys Very Happy ,

I just see this post yet, thanks a lot.

I think ....
Code:
#define CRYPT_MODE_ECB          2       // Electronic code book

... will work.

juppy Cool
_________________
http://securityvision.ch
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group