| View previous topic :: View next topic |
| Author |
Message |
IsNull
Joined: 10 May 2007 Posts: 64 Location: .switzerland
|
Posted: Sat May 03, 2008 6:16 pm Post subject: AES encryption: Translate Phyton code into AHK... |
|
|
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
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
Hope somebody can help
Regards
IsNull _________________ http://securityvision.ch
 |
|
| Back to top |
|
 |
greynite
Joined: 17 May 2008 Posts: 11
|
Posted: Mon May 19, 2008 5:16 pm Post subject: |
|
|
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 |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Mon May 19, 2008 5:22 pm Post subject: |
|
|
probably you're missing this _________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
greynite
Joined: 17 May 2008 Posts: 11
|
Posted: Mon May 19, 2008 11:05 pm Post subject: |
|
|
| 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 |
|
 |
Guest
|
Posted: Mon May 19, 2008 11:57 pm Post subject: |
|
|
| 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
|
Posted: Tue May 20, 2008 9:14 am Post subject: |
|
|
| 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 |
|
 |
IsNull
Joined: 10 May 2007 Posts: 64 Location: .switzerland
|
Posted: Sun Jul 20, 2008 12:23 pm Post subject: |
|
|
Hey you guys ,
I just see this post yet, thanks a lot.
I think ....
| Code: | | #define CRYPT_MODE_ECB 2 // Electronic code book |
... will work.
juppy  _________________ http://securityvision.ch
 |
|
| Back to top |
|
 |
|