fb:porticula NoPaste
md5.bi
Uploader: | Michael |
Datum/Zeit: | 04.09.2007 17:33:01 |
'' Headerfile for md5.bas
type MD5Context
buf(0 to 3) as unsigned integer
bits(0 to 1) as unsigned integer
in(0 to 63) as ubyte
end type
declare sub MD5Init(byval ctx as MD5Context ptr)
declare sub MD5Update(byval ctx as MD5Context ptr, byval buf as ubyte ptr, byval llen as unsigned integer)
declare sub MD5Final(byval digest as ubyte ptr, byval ctx as MD5Context ptr)
declare sub MD5Transform (byval buf as integer ptr, byval in as integer ptr)
#include "md5.bas"
Function md5(text As String) As String
Dim As MD5Context ctx
Dim As ubyte md5sum(0 to 15)
Dim As String s
Dim As Zstring * 33 ooutput
MD5Init(@ctx)
MD5Update(@ctx, strptr(text), Len(text))
MD5Final(@md5sum(0), @ctx)
For j As Integer = 0 to 15
s = hex(md5sum(j))
if len(s) = 1 then s = "0" + s
ooutput[j * 2] = lcase(s)
Next
Return ooutput
End Function