1 |
joko |
1.1 |
Attribute VB_Name = "MD5" |
2 |
|
|
' MD5.bas - wrapper for RSA MD5 DLL |
3 |
|
|
' derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm |
4 |
|
|
' Functions: |
5 |
|
|
' MD5String (some string) -> MD5 digest of the given string as 32 bytes string |
6 |
|
|
' MD5File (some filename) -> MD5 digest of the file's content as a 32 bytes string |
7 |
|
|
' returns a null terminated "FILE NOT FOUND" if unable to open the |
8 |
|
|
' given filename for input |
9 |
|
|
' Bugs, complaints, etc: |
10 |
|
|
' Francisco Carlos Piragibe de Almeida |
11 |
|
|
' piragibe@esquadro.com.br |
12 |
|
|
' History |
13 |
|
|
' Apr, 17 1999 - fixed the null byte problem |
14 |
|
|
' Contains public domain RSA C-code for MD5 digest (see MD5-original.txt file) |
15 |
|
|
' The aamd532.dll DLL MUST be somewhere in your search path |
16 |
|
|
' for this to work |
17 |
|
|
Private Declare Sub MDFile Lib "aamd532.dll" (ByVal f As String, ByVal r As String) |
18 |
|
|
Private Declare Sub MDStringFix Lib "aamd532.dll" (ByVal f As String, ByVal t As Long, ByVal r As String) |
19 |
|
|
|
20 |
|
|
Public Function MD5String(p As String) As String |
21 |
|
|
' compute MD5 digest on a given string, returning the result |
22 |
|
|
Dim r As String * 32, t As Long |
23 |
|
|
r = Space(32) |
24 |
|
|
t = Len(p) |
25 |
|
|
MDStringFix p, t, r |
26 |
|
|
MD5String = r |
27 |
|
|
End Function |
28 |
|
|
|
29 |
|
|
Public Function MD5File(f As String) As String |
30 |
|
|
' compute MD5 digest on o given file, returning the result |
31 |
|
|
Dim r As String * 32 |
32 |
|
|
r = Space(32) |
33 |
|
|
MDFile f, r |
34 |
|
|
MD5File = r |
35 |
|
|
End Function |
36 |
|
|
|