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 

AHK Functions : FileMD5() / MD5() [Updated]
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Laszlo



Joined: 14 Feb 2005
Posts: 4516
Location: Boulder, CO

PostPosted: Thu Jun 18, 2009 5:25 pm    Post subject: Reply with quote

Nice! I guess the right size is VarSetCapacity(MD5_CTX,104), though. Anything larger works, too. The string version at the second dll call needs VarSetCapacity(V) at the end of the line, not VarSetCapacity(L).

Also, the right offset to read the digest from is 87+A_Index. 7+A_Index works, too, but it is not the intended place.

It is not a fair rosettacode solution, because the work is done in the Windows advapi32.dll, not in AHK. I am not even sure if machine code functions qualify, because they are processor dependent, not in the control of AHK.


Last edited by Laszlo on Thu Jun 18, 2009 5:42 pm; edited 1 time in total
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7185

PostPosted: Thu Jun 18, 2009 5:40 pm    Post subject: Reply with quote

infogulch wrote:
Cool MD5 functions!


Thanks! Smile


Laszlo wrote:
I guess the right size is VarSetCapacity(MD5_CTX,104)


I do not understand that struct at all!.. I vaguely picked that number from here

Quote:
It is not a fair rosettacode solution, because the work is done in the Windows advapi32.dll, not in AHK.


I agree Sir. Maybe you can consider posting your native implementation of MD5()

Smile
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4516
Location: Boulder, CO

PostPosted: Thu Jun 18, 2009 5:46 pm    Post subject: Reply with quote

MSDN says:
Code:
typedef struct {
  ULONG         i[2];
  ULONG         buf[4];
  unsigned char in[64];
  unsigned char digest[16];
} MD5_CTX;
It is 2*4+4*4+64+16 = 104 bytes. The offset for the result (digest) is 88.
Back to top
View user's profile Send private message
infogulch



Joined: 27 Mar 2008
Posts: 378

PostPosted: Thu Jun 18, 2009 5:47 pm    Post subject: Reply with quote

Shocked oops. I didn't know you had already done that, Laszlo. I agree with SKAN, you should post yours on rosetta code.
_________________

Scripts
- License
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7185

PostPosted: Thu Jun 18, 2009 6:23 pm    Post subject: Reply with quote

Laszlo wrote:
It is 2*4+4*4+64+16 = 104 bytes.


Thank you Sir. Smile

Laszlo wrote:
The offset for the result (digest) is 88.


Shocked

I did not view that far with my Binspector. Seeing that the digest is also available at offset 8, I happily contended with 24 until I noticed I am not getting proper results for small strings.

Thanks again for the clarification..

Edit: I have updated the code with right VarSetCapacity and corrected the Message offset to read from.
Back to top
View user's profile Send private message
fragman



Joined: 13 Oct 2009
Posts: 95

PostPosted: Fri Jan 08, 2010 2:32 pm    Post subject: Reply with quote

ShellFileOperation doesn't work with FTP servers. Calling it like this:
ShellFileOperation(0x2,"C:\Program Files\AutoHotkey\main.exe","ftp://user@autohotkey.net/",0,0)

Shows a dialog asking if a path "C:\Program Files\AutoHotkey\ftp:\" should be created, and then it either fails with a Cancelled error system code or with a 123 code indicating a path with wrong format.

For now I'm going to avoid that by using a different transfer function for ftp, but it would be nice to see the windows dialogs for it, and I believe it should be possible since explorer can do it.
Back to top
View user's profile Send private message
OceanMachine



Joined: 15 Oct 2007
Posts: 277

PostPosted: Thu Mar 11, 2010 9:07 pm    Post subject: Reply with quote

fragman wrote:
ShellFileOperation doesn't work with FTP servers... I believe it should be possible since explorer can do it.


I think that when you put the ftp protocol in the address bar of explorer (i.e. typing ftp://whatever), windows actually swiches to using Internet Explorer to do that for you, and not Explorer (the file explorer). So Explorer can't do it... (as far as I am aware). It's not a standard Shell File Operation.

Try something like this WININET wrapper for an FTP solution.

Another alternative is to use this libcURL wrapper.
Back to top
View user's profile Send private message
fragman



Joined: 13 Oct 2009
Posts: 95

PostPosted: Thu Mar 11, 2010 9:09 pm    Post subject: Reply with quote

I'm currently transferring files using the wrapper, but I want to show native transfer dialogs, so the user can also get replacement questions, progress etc.

(internet?) Explorer can do the transfer, even with files from clipboard, maybe I can find a way to remote control a hidden explorer window or so.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9
Page 9 of 9

 
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