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 

File Standard Library
Goto page Previous  1, 2
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
olfen



Joined: 04 Jun 2005
Posts: 113
Location: Stuttgart, Germany

PostPosted: Wed Sep 26, 2007 5:46 pm    Post subject: Reply with quote

Thanks, Sean!
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Mon Oct 01, 2007 5:51 am    Post subject: Reply with quote

I combined the recent AES.ahk and Hash.ahk into StandardLibrary File.ahk.

Example:
Code:
sFileOriginl   := A_AhkPath    ; Specify the real file path here!
sPassword   := "AutoHotkey"    ; Specify your own password here!

SID := 128   ; 128bit AES
sFileEncrypt := A_Temp . "\encrypt" . SID . ".bin"    ; Specify encrypted file path.
sFileDecrypt := A_Temp . "\decrypt" . SID . ".exe"    ; Specify decrypted file path.
File_AES(sFileOriginl, sFileEncrypt, sPassword, SID, True)    ; Encryption
File_AES(sFileEncrypt, sFileDecrypt, sPassword, SID, False)   ; Decryption

SID := 192   ; 192bit AES
sFileEncrypt := A_Temp . "\encrypt" . SID . ".bin"
sFileDecrypt := A_Temp . "\decrypt" . SID . ".exe"
File_AES(sFileOriginl, sFileEncrypt, sPassword, SID, True)    ; Encryption
File_AES(sFileEncrypt, sFileDecrypt, sPassword, SID, False)   ; Decryption

SID := 256   ; 256bit AES
sFileEncrypt := A_Temp . "\encrypt" . SID . ".bin"
sFileDecrypt := A_Temp . "\decrypt" . SID . ".exe"
File_AES(sFileOriginl, sFileEncrypt, sPassword, SID, True)    ; Encryption
File_AES(sFileEncrypt, sFileDecrypt, sPassword, SID, False)   ; Decryption

MsgBox, % "CRC32:`t"   . File_Hash(sFileOriginl, "CRC32")   . "`n"
   . "MD5:`t"   . File_Hash(sFileOriginl, "MD5")   . "`n"
   . "SHA1:`t"   . File_Hash(sFileOriginl, "SHA1")   . "`n"
Back to top
View user's profile Send private message
Theolonious



Joined: 05 Jan 2008
Posts: 2
Location: syracuse,ny

PostPosted: Tue Jan 08, 2008 7:34 pm    Post subject: Reply with quote

[quote="majkinetor"]
Quote:


Sad to know you have grown up. My deepest symphaties. Crying or Very sad


I tell my Girlfriend that all men are 12 years old. Otherwise we would not have so many toys. 13 is bad luck and over the hill.


My apologies for posting to an old message but i could not resist.
Back to top
View user's profile Send private message
Tuncay



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Tue Mar 09, 2010 4:00 am    Post subject: Reply with quote

Edit: My usage was not correct! sorry forget about this post.
The Crypt_Hash() does not calculate / get correct md5. I am using Vista here.
Code:
; #Include Crypt.ahk
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

V := "The quick brown fox jumps over the lazy dog"
L := StrLen(V)
MsgBox,, MD5 with Crypt_Hash(), % V . ":`n`n" . Crypt_Hash(V, L, "MD5")

_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--


Last edited by Tuncay on Wed Mar 10, 2010 11:43 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Wed Mar 10, 2010 12:20 am    Post subject: Reply with quote

Your usage is wrong.
Code:
Crypt_Hash(&V, L, "MD5")
Back to top
View user's profile Send private message
Tuncay



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Wed Mar 10, 2010 8:32 am    Post subject: Reply with quote

Ok, sorry for this Sean. I make a notice to that posting, not to fooling others.
_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--
Back to top
View user's profile Send private message Send e-mail Visit poster's website
PanicSwitch
Guest





PostPosted: Tue Mar 30, 2010 6:27 pm    Post subject: Reply with quote

Hello All--

I have been trying to use the string encryption from this post: http://www.autohotkey.com/forum/topic23719.html&postdays=0&postorder=asc&highlight=aes&start=15

Pretty much I take the encrypted string and write it to an INI file for reading/decryption later. Running tests with the code, however, only allows me to successfully decrypt once.

Code:
!+F12::
   SID := 128   ; 256bit AES
   pKey := "n0disassemble"
   KeyWait, Alt, L
   KeyWait, LShift, L
   InputBox, pPassword, Macro Password, Please Specify Windows Password (It will be encrypted):,,300,125
   pPassword = %pPassword%
   nSize := Text_AES(sTextEncrypt, &pPassword, StrLen(pPassword), pKey, SID, True)   ; Encryption
   IniWrite, %sTextEncrypt%, macro.ini, User, Password
   pPassword = 1234567
   InputBox, pPassphrase, Macro Password, Please Specify PassPhrase (It will be encrypted):,,300,125
   pPassphrase = %pPassphrase%
   nSize := Text_AES(sTextEncrypt, &pPassphrase, StrLen(pPassphrase), pKey, SID, True)   ; Encryption
   IniWrite, %sTextEncrypt%, macro.ini, User, Passphrase
   pPassphrase = 1234567
   return
+^F12::
   SID := 128   ; 256bit AES
   pKey := "n0disassemble"
   KeyWait, Control, L
   KeyWait, LShift, L
   IniRead, pPassword, macro.ini, User, Password, 0
   nSize := Text_AES(pWordDecrypt, &pPassword, nSize, pKey, SID, False)   ; Decryption
   MsgBox % pWordDecrypt
   IniRead, pPassphrase, macro.ini, User, Passphrase, 0
   nSize := Text_AES(pPhraseDecrypt, &pPassphrase, nSize, pKey, SID, False)   ; Decryption
   MsgBox % pPhraseDecrypt


Again this is more proof of concept, once I get it to work properly, I'll clean up the code, move the key definitions, etc.

Text_AES is defined as noted here:

Code:


Text_AES(ByRef sResult, pData, nSize, sPassword, SID = 256, bEncrypt = True)
{
   VarSetCapacity(sResult, bEncrypt ? nSize+16 : nSize)
   DllCall("RtlMoveMemory", "Uint", &sResult, "Uint", pData, "Uint", nSize)
   nSize := Crypt_AES(&sResult, nSize, sPassword, SID, bEncrypt)
   NumPut(0, sResult, nSize, "char"), VarSetCapacity(sResult,-1)
   Return   nSize
}


When I check the encrypted string in the INI file, they look identical but when I decrypt, the first will come out fine...the second will come up as a completely different string.

Any help would be appreciated.
Back to top
moruls
Guest





PostPosted: Wed Jul 20, 2011 8:07 am    Post subject: Reply with quote

Anyway filehelper can strip our char(13) carriage returns ?

Ideally as an option !!
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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