DLLs | | | | Sven Bader | Download
Hello together,
again would like I a small DLL provide. ex the 5. DLL create I then a single with all functions
it can MD5 Prüfsummen from Strings Generate, which one known for diverse tack bring into action can. I have plenty tested be me but the strength and Korrektheit not yet 100% sure. i am pleased here means on Feedback!
greetings Sven
here one Beispielaufruf. it need a small Hilfsfunktion, there Funktionsaufrufe and Rückgaben in DLLs Strings only as address process can:
or integrally without DLL nativ in XProfan. at that Compilieren in XProfan instead of Profan2CPP should The Compileranweisung in the "Proc md5_rl" yet removes go. the unsigned right shift <<<, a couple | = Zuweisungen and the Tilde ~ (Bitwise hardship) had I paraphrase, there it these in XProfan not gives. I basiere incidentally on the C++ Code Paul Johnston [...]
Def md5_tilde(1) (&(1) * (-1) -1)'~
Declare md5_x&[524288], md5_hc$
'right shift unsigned >>>
Proc md5_rsu
Parameters a&, b&
Declare x&
x& = a& >> b&
whileloop 0, b&-1
x& = setbit(x&,31-&loop,0)
endwhile
return x&
ENDPROC
Proc md5_rh
Parameters n&
Declare j&, s$
s$ = ""
Whileloop 0, 3
j& = &loop
s$ = s$ + Mid$(md5_hc$, ((n& >> (j&*8 + 4)) & $0F)+1,1) + Mid$(md5_hc$, ((n& >> (j&*8)) & $0F)+1,1)
Endwhile
return s$
ENDPROC
Proc md5_ad
Parameters x&, y&
Declare l&, m&, return&
l& = (x& & $FFFF) + (y& & $FFFF)
m& = (x& >> 16) + (y& >> 16) + (l& >> 16)
return& = (m& << 16) | (l& & $FFFF)
return return&
ENDPROC
Proc md5_rl
Declare return&
$IFDEF COMPILER
'P2CPP: <INLINE_CPP>
unsigned long lN = LongParam(1);
unsigned long lC = LongParam(2);
unsigned unsigned rr = (lN >> (32 - lC));
lReturn = _L(((lN << lC))) | _L(rr);
'P2CPP: </INLINE_CPP>
$ELSE
Parameters n&,c&
return& = (n& << c&) | md5_rsu(n&,(32-c&))
$ENDIF
return return&
Endproc
Proc md5_cm
Parameters q&,a&,b&,x&,s&,t&
Declare return&
return& = md5_ad(md5_rl(md5_ad(md5_ad(a&,q&),md5_ad(x&,t&)),s&),b&)
return return&
ENDPROC
Proc md5_ff
Parameters a&,b&,c&,d&,x&,s&,t&
Declare return&
return& = md5_cm(((b& & c&) | (md5_tilde(b&) & d&)),a&,b&,x&,s&,t&)
return return&
ENDPROC
Proc md5_gg
Parameters a&,b&,c&,d&,x&,s&,t&
Declare return&
return& = md5_cm((b& & d&) | (c& & md5_tilde(d&)),a&,b&,x&,s&,t&)
return return&
ENDPROC
Proc md5_hh
Parameters a&,b&,c&,d&,x&,s&,t&
Declare return&
return& = md5_cm(xor(xor(b&, c&), d&),a&,b&,x&,s&,t&)
return return&
ENDPROC
Proc md5_ii
Parameters a&,b&,c&,d&,x&,s&,t&
Declare return&
return& = md5_cm(XOR(c&, (b& | md5_tilde(d&))),a&,b&,x&,s&,t&)
return return&
ENDPROC
Proc md5_sb
Parameters x$
Declare i&, nblk&, return&
nblk& = ((len(x$) + 8) >> 6) + 1
Whileloop 0, (nblk&*16 - 1)
i& = &loop
md5_x&[i&] = 0
Endwhile
Whileloop 0, (len(x$) - 1)
i& = &loop
md5_x&[i& >> 2] = md5_x&[i& >> 2] | (ord(Mid$(x$,i&+1,1)) << ((i& MOD 4)*8))
Endwhile
inc i&
md5_x&[i& >> 2] = md5_x&[i& >> 2] | ($80 << (((i&) MOD 4)*8))
md5_x&[nblk&*16-2] = len(x$)*8
return& = nblk&*16
return return&
ENDPROC
Proc md5
parameters inputString$
declare a&,b&,c&,d&,olda&,oldb&,oldc&,oldd&,i&,lenx&
md5_hc$ = "0123456789abcdef"
lenx& = md5_sb(inputString$)
'messagebox st$(lenx& ),"",0
a& = 1732584193
b& = -271733879
c& = -1732584194
d& = 271733878
' messagebox st$(lenx&),"",0
While i& < lenx&
olda& = a&
oldb& = b&
oldc& = c&
oldd& = d&
a& = md5_ff(a&,b&,c&,d&,md5_x&[i& + 0], 7, -680876936)
d& = md5_ff(d&,a&,b&,c&,md5_x&[i& + 1],12, -389564586)
c& = md5_ff(c&,d&,a&,b&,md5_x&[i& + 2],17, 606105819)
b& = md5_ff(b&,c&,d&,a&,md5_x&[i& + 3],22,-1044525330)
a& = md5_ff(a&,b&,c&,d&,md5_x&[i& + 4], 7, -176418897)
d& = md5_ff(d&,a&,b&,c&,md5_x&[i& + 5],12, 1200080426)
c& = md5_ff(c&,d&,a&,b&,md5_x&[i& + 6],17,-1473231341)
b& = md5_ff(b&,c&,d&,a&,md5_x&[i& + 7],22, -45705983)
a& = md5_ff(a&,b&,c&,d&,md5_x&[i& + 8], 7, 1770035416)
d& = md5_ff(d&,a&,b&,c&,md5_x&[i& + 9],12,-1958414417)
c& = md5_ff(c&,d&,a&,b&,md5_x&[i& + 10],17, -42063)
b& = md5_ff(b&,c&,d&,a&,md5_x&[i& + 11],22,-1990404162)
a& = md5_ff(a&,b&,c&,d&,md5_x&[i& + 12], 7, 1804603682)
d& = md5_ff(d&,a&,b&,c&,md5_x&[i& + 13],12, -40341101)
c& = md5_ff(c&,d&,a&,b&,md5_x&[i& + 14],17,-1502002290)
b& = md5_ff(b&,c&,d&,a&,md5_x&[i& + 15],22, 1236535329)
a& = md5_gg(a&,b&,c&,d&,md5_x&[i& + 1], 5, -165796510)
d& = md5_gg(d&,a&,b&,c&,md5_x&[i& + 6], 9,-1069501632)
c& = md5_gg(c&,d&,a&,b&,md5_x&[i& + 11],14, 643717713)
b& = md5_gg(b&,c&,d&,a&,md5_x&[i& + 0],20, -373897302)
a& = md5_gg(a&,b&,c&,d&,md5_x&[i& + 5], 5, -701558691)
d& = md5_gg(d&,a&,b&,c&,md5_x&[i& + 10], 9, 38016083)
c& = md5_gg(c&,d&,a&,b&,md5_x&[i& + 15],14, -660478335)
b& = md5_gg(b&,c&,d&,a&,md5_x&[i& + 4],20, -405537848)
a& = md5_gg(a&,b&,c&,d&,md5_x&[i& + 9], 5, 568446438)
d& = md5_gg(d&,a&,b&,c&,md5_x&[i& + 14], 9,-1019803690)
c& = md5_gg(c&,d&,a&,b&,md5_x&[i& + 3],14, -187363961)
b& = md5_gg(b&,c&,d&,a&,md5_x&[i& + 8],20, 1163531501)
a& = md5_gg(a&,b&,c&,d&,md5_x&[i& + 13], 5,-1444681467)
d& = md5_gg(d&,a&,b&,c&,md5_x&[i& + 2], 9, -51403784)
c& = md5_gg(c&,d&,a&,b&,md5_x&[i& + 7],14, 1735328473)
b& = md5_gg(b&,c&,d&,a&,md5_x&[i& + 12],20,-1926607734)
a& = md5_hh(a&,b&,c&,d&,md5_x&[i& + 5], 4, -378558)
d& = md5_hh(d&,a&,b&,c&,md5_x&[i& + 8],11,-2022574463)
c& = md5_hh(c&,d&,a&,b&,md5_x&[i& + 11],16, 1839030562)
b& = md5_hh(b&,c&,d&,a&,md5_x&[i& + 14],23, -35309556)
a& = md5_hh(a&,b&,c&,d&,md5_x&[i& + 1], 4,-1530992060)
d& = md5_hh(d&,a&,b&,c&,md5_x&[i& + 4],11, 1272893353)
c& = md5_hh(c&,d&,a&,b&,md5_x&[i& + 7],16, -155497632)
b& = md5_hh(b&,c&,d&,a&,md5_x&[i& + 10],23,-1094730640)
a& = md5_hh(a&,b&,c&,d&,md5_x&[i& + 13], 4, 681279174)
d& = md5_hh(d&,a&,b&,c&,md5_x&[i& + 0],11, -358537222)
c& = md5_hh(c&,d&,a&,b&,md5_x&[i& + 3],16, -722521979)
b& = md5_hh(b&,c&,d&,a&,md5_x&[i& + 6],23, 76029189)
a& = md5_hh(a&,b&,c&,d&,md5_x&[i& + 9], 4, -640364487)
d& = md5_hh(d&,a&,b&,c&,md5_x&[i& + 12],11, -421815835)
c& = md5_hh(c&,d&,a&,b&,md5_x&[i& + 15],16, 530742520)
b& = md5_hh(b&,c&,d&,a&,md5_x&[i& + 2],23, -995338651)
a& = md5_ii(a&,b&,c&,d&,md5_x&[i& + 0], 6, -198630844)
d& = md5_ii(d&,a&,b&,c&,md5_x&[i& + 7],10, 1126891415)
c& = md5_ii(c&,d&,a&,b&,md5_x&[i& + 14],15,-1416354905)
b& = md5_ii(b&,c&,d&,a&,md5_x&[i& + 5],21, -57434055)
a& = md5_ii(a&,b&,c&,d&,md5_x&[i& + 12], 6, 1700485571)
d& = md5_ii(d&,a&,b&,c&,md5_x&[i& + 3],10,-1894986606)
c& = md5_ii(c&,d&,a&,b&,md5_x&[i& + 10],15, -1051523)
b& = md5_ii(b&,c&,d&,a&,md5_x&[i& + 1],21,-2054922799)
a& = md5_ii(a&,b&,c&,d&,md5_x&[i& + 8], 6, 1873313359)
d& = md5_ii(d&,a&,b&,c&,md5_x&[i& + 15],10, -30611744)
c& = md5_ii(c&,d&,a&,b&,md5_x&[i& + 6],15,-1560198380)
b& = md5_ii(b&,c&,d&,a&,md5_x&[i& + 13],21, 1309151649)
a& = md5_ii(a&,b&,c&,d&,md5_x&[i& + 4], 6, -145523070)
d& = md5_ii(d&,a&,b&,c&,md5_x&[i& + 11],10,-1120210379)
c& = md5_ii(c&,d&,a&,b&,md5_x&[i& + 2],15, 718787259)
b& = md5_ii(b&,c&,d&,a&,md5_x&[i& + 9],21, -343485551)
a& = md5_ad(a&,olda&)
b& = md5_ad(b&,oldb&)
c& = md5_ad(c&,oldc&)
d& = md5_ad(d&,oldd&)
i& = i& + 16
EndWhile
Return (md5_rh(a&) + md5_rh(b&) + md5_rh(c&) + md5_rh(d&))
ENDPROC
cls
declare time&
time& = &gettickcount
print "Hallo world: "+md5("Hallo Welt")
print "ÄÖÜ: "+md5(Utf8Encode("ÄÖÜ"))
print (&gettickcount-time&)
waitkey
end
|
| | | | |
| | Sven Bader | Habs once more updated. The DLL is now faster and processing Umlaute etc. correctly. |
| | | | |
| | Sven Bader | i was once more dran and I The DLL updated. its now possible, Files Verify. the eignet itself, circa in example Manipulationen or other Beschädigungen on Programmdateien To Verify, can but a little bit last.
declare hDll&, Text$
let hDll& = @UseDll("md5.dll")
ImportFunc(hDll&,"md5", "md5DLL")
ImportFunc(hDll&,"md5_file", "md5_fileDLL")
Proc md5
Parameters inputstring$
Declare target#
Dim target#, 33
md5DLL(Addr(inputstring$), target#)
Return string $(target#,0)
ENDPROC
Proc md5_file
Parameters inputstring$
Declare target#
Dim target#, 33
md5_fileDLL(Addr(inputstring$), target#)
Return string $(target#,0)
ENDPROC
Cls
declare time&
time& = &gettickcount
Print "a) Zeichenkette \qtest\q:"
Print "098f6bcd4621d373cade4e832627b4f6"
Print md5("test")
Print ""
Print "b) File md5.dll:"
Print "fa7a65f6042653776b524d829e5aef2b"
Print md5_file("md5.dll")
Print ""
Print "c) 1024 space:"
Print "10801b757893f9edbff42cd92fdd406a"
Print md5(space$(1024))
Print ""
Print st$(int(&gettickcount-time&)) + "ms"
Waitinput
FreeDll hDll&
End
|
| | | | |
| | Georg Teles | Nabend,
for Dateiprüfung can You possible The function MapFileAndCheckSum use:
or here [...] have I the View source posted, How in windows these function accounts, here the blanke code (lasts too at Perform, as nProc runs it however too with large Files To 2 Gb relatively quick, The File must as Ganzes hineingelesen go, eignet itself means for Files, The not entpackt go must as Bsp., the was my Intention then for Manipulationsschutz or. CheckSumme in my Archivierer):
Set("FileMode",0)
Assign #1,file$
OpenRW #1
BlockRead(#1,ber#,0,size&)
cr2& = cr2(ber#,size&)
Close #1
nProc cr2
Parameters ber#,ps&
Declare s&,res&
s& = 0
res& = 0
If ps& MOD 2 = 0
s& = (ps&\2)-1
Else
s& = (ps&\2)
EndIf
WhileLoop 0,s&
res& = res&+word(ber#,&loop*2)
If res& > 65534
res& = (res&-65535)
Endif
EndWhile
res& = (res&+ps&)
Return res&
ENDPROC
Regards Georg |
| | | | |
| | Sven Bader | Hello Georg,
The MapFileAndCheckSumA function is interestingly and quick enough. The 32 Bits can well as Integer take off, The MD5 Prüfsummen of 128 bit schleift one sooner time as String with, are then but too sure never twice.
The development the DLL was exceptionally times not from Eigenbedarf, I had just Fun on it 2 Gb would I so now not Verify but meanwhile weg ca. 10 MB per second, The MapFileAndCheckSumA is there about 10x faster, has but too less To do.
can you me say, welchem standard your cr2 function or The MapFileAndCheckSum having? I could The Results not validieren, one CRC32 or 16 shining not To his.
Regards Sven |
| | | | |
| | Georg Teles | Hi Sven,
good question, I can only so much say, that these function a "Restwert" the WORD (2 Bytes) to Filesize add, the Result is then The Checksumme:
WORD 1 and WORD 2 the File go add (means first 2 Bytes with the next 2 Bytes), ought to the worth same or. over 65.535 total (Max. worth the WORD), becomes this abgezogen.
To this remainder becomes the next WORD (2 Bytes) add and again compared and abgezogen, To the Dateiende access is ... to that Schluss becomes the Result, means the RestWORD, The Filesize add. the Result is then The amount the RestWORD and the Filesize.
loudly MS watts these Fuktion against manipulation ausführbarer Files develops, so The CheckSumme directly in whom Header the EXE File written becomes (at Compile).
means, if is a EXE File with this Fuktion abfragt and these in the Header The CheckSumme own, becomes these Fuktion the value simply read and spend (or. at Perform with the File self vergleichen, HeadSum with CheckSum, whether manipulating watts) ... if The EXE File no CheckSumme own, becomes these accounts, one comparison and a Message bzgl. manipulation entfällt.
These function can but on any Files utilize, since the Berechnung quite quick goes withal great Files.
so seen has these function no rule take I.
Regards Georg |
| | | | |
|
Zur DLLThemeninformationenthis Topic has 2 subscriber: |