求购MD5算法的源文件For Delphi6或者Dll什么的(100分)

  • 主题发起人 主题发起人 tong_hui
  • 开始时间 开始时间
T

tong_hui

Unregistered / Unconfirmed
GUEST, unregistred user!
求购MD5算法的源文件For Delphi6或者Dll什么的,最好带有例题了,还有delphi6中的indy带有的
md5怎么使用啊?
 
在2001程序员大本营--borland版的光盘上有这个算法
 
我有ASP的:
注:以上内容可以生成128位的结果,但原作者为了把它放到自己的数据库中,
只取了中间的64位,这点你要注意一下。
另外,DELPHI的我也有,先给分我就告诉你。

MD5不可逆加密算法的ASP实现实例
2002-2-6 动网先锋
此为国外转载函数,可将任意字符转换为md5 16为字符加密形式,而且为不可逆转换。
<%
Private Const BITS_TO_A_BYTE = 8
Private Const BYTES_TO_A_WORD = 4
Private Const BITS_TO_A_WORD = 32
Private m_lOnBits(30)
Private m_l2Power(30)
Private Function LShift(lValue, iShiftBits)
If iShiftBits = 0 then
LShift = lValue
Exit Function
else
If iShiftBits = 31 then
If lValue And 1 then
LShift = &H80000000
else
LShift = 0
End If
Exit Function
else
If iShiftBits < 0 Or iShiftBits > 31 then
Err.Raise 6
End If
If (lValue And m_l2Power(31 - iShiftBits)) then
LShift = ((lValue And m_lOnBits(31 - (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000
else
LShift = ((lValue And m_lOnBits(31 - iShiftBits)) * m_l2Power(iShiftBits))
End If
End Function
Private Function RShift(lValue, iShiftBits)
If iShiftBits = 0 then
RShift = lValue
Exit Function
else
If iShiftBits = 31 then
If lValue And &H80000000 then
RShift = 1
else
RShift = 0
End If
Exit Function
else
If iShiftBits < 0 Or iShiftBits > 31 then
Err.Raise 6
End If
RShift = (lValue And &H7FFFFFFE) / m_l2Power(iShiftBits)
If (lValue And &H80000000) then
RShift = (RShift Or (&H40000000 / m_l2Power(iShiftBits - 1)))
End If
End Function
Private Function RotateLeft(lValue, iShiftBits)
RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 - iShiftBits))
End Function
Private Function AddUnsigned(lX, lY)
Dim lX4
Dim lY4
Dim lX8
Dim lY8
Dim lResult
lX8 = lX And &H80000000
lY8 = lY And &H80000000
lX4 = lX And &H40000000
lY4 = lY And &H40000000
lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF)
If lX4 And lY4 then
lResult = lResult Xor &H80000000 Xor lX8 Xor lY8
else
If lX4 Or lY4 then
If lResult And &H40000000 then
lResult = lResult Xor &HC0000000 Xor lX8 Xor lY8
else
lResult = lResult Xor &H40000000 Xor lX8 Xor lY8
End If
else
lResult = lResult Xor lX8 Xor lY8
End If
AddUnsigned = lResult
End Function
Private Function md5_F(x, y, z)
md5_F = (x And y) Or ((Not x) And z)
End Function
Private Function md5_G(x, y, z)
md5_G = (x And z) Or (y And (Not z))
End Function
Private Function md5_H(x, y, z)
md5_H = (x Xor y Xor z)
End Function
Private Function md5_I(x, y, z)
md5_I = (y Xor (x Or (Not z)))
End Function
Private Sub md5_FF(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_F(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub md5_GG(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_G(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub md5_HH(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_H(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Sub md5_II(a, b, c, d, x, s, ac)
a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_I(b, c, d), x), ac))
a = RotateLeft(a, s)
a = AddUnsigned(a, b)
End Sub
Private Function ConvertToWordArray(sMessage)
Dim lMessageLength
Dim lNumberOfWords
Dim lWordArray()
Dim lBytePosition
Dim lByteCount
Dim lWordCount
Const MODULUS_BITS = 512
Const CONGRUENT_BITS = 448
lMessageLength = Len(sMessage)
lNumberOfWords = (((lMessageLength + ((MODULUS_BITS - CONGRUENT_BITS) / BITS_TO_A_BYTE)) / (MODULUS_BITS / BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS / BITS_TO_A_WORD)
ReDim lWordArray(lNumberOfWords - 1)
lBytePosition = 0
lByteCount = 0
Do Until lByteCount >= lMessageLength
lWordCount = lByteCount / BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition)
lByteCount = lByteCount + 1
Loop
lWordCount = lByteCount / BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(&H80, lBytePosition)
lWordArray(lNumberOfWords - 2) = LShift(lMessageLength, 3)
lWordArray(lNumberOfWords - 1) = RShift(lMessageLength, 29)
ConvertToWordArray = lWordArray
End Function
Private Function WordToHex(lValue)
Dim lByte
Dim lCount
For lCount = 0 To 3
lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits(BITS_TO_A_BYTE - 1)
WordToHex = WordToHex &
Right("0" &
Hex(lByte), 2)
Next
End Function
Public Function MD5(sMessage)
m_lOnBits(0) = CLng(1)
m_lOnBits(1) = CLng(3)
m_lOnBits(2) = CLng(7)
m_lOnBits(3) = CLng(15)
m_lOnBits(4) = CLng(31)
m_lOnBits(5) = CLng(63)
m_lOnBits(6) = CLng(127)
m_lOnBits(7) = CLng(255)
m_lOnBits(8) = CLng(511)
m_lOnBits(9) = CLng(1023)
m_lOnBits(10) = CLng(2047)
m_lOnBits(11) = CLng(4095)
m_lOnBits(12) = CLng(8191)
m_lOnBits(13) = CLng(16383)
m_lOnBits(14) = CLng(32767)
m_lOnBits(15) = CLng(65535)
m_lOnBits(16) = CLng(131071)
m_lOnBits(17) = CLng(262143)
m_lOnBits(18) = CLng(524287)
m_lOnBits(19) = CLng(1048575)
m_lOnBits(20) = CLng(2097151)
m_lOnBits(21) = CLng(4194303)
m_lOnBits(22) = CLng(8388607)
m_lOnBits(23) = CLng(16777215)
m_lOnBits(24) = CLng(33554431)
m_lOnBits(25) = CLng(67108863)
m_lOnBits(26) = CLng(134217727)
m_lOnBits(27) = CLng(268435455)
m_lOnBits(28) = CLng(536870911)
m_lOnBits(29) = CLng(1073741823)
m_lOnBits(30) = CLng(2147483647)
m_l2Power(0) = CLng(1)
m_l2Power(1) = CLng(2)
m_l2Power(2) = CLng(4)
m_l2Power(3) = CLng(8)
m_l2Power(4) = CLng(16)
m_l2Power(5) = CLng(32)
m_l2Power(6) = CLng(64)
m_l2Power(7) = CLng(128)
m_l2Power(8) = CLng(256)
m_l2Power(9) = CLng(512)
m_l2Power(10) = CLng(1024)
m_l2Power(11) = CLng(2048)
m_l2Power(12) = CLng(4096)
m_l2Power(13) = CLng(8192)
m_l2Power(14) = CLng(16384)
m_l2Power(15) = CLng(32768)
m_l2Power(16) = CLng(65536)
m_l2Power(17) = CLng(131072)
m_l2Power(18) = CLng(262144)
m_l2Power(19) = CLng(524288)
m_l2Power(20) = CLng(1048576)
m_l2Power(21) = CLng(2097152)
m_l2Power(22) = CLng(4194304)
m_l2Power(23) = CLng(8388608)
m_l2Power(24) = CLng(16777216)
m_l2Power(25) = CLng(33554432)
m_l2Power(26) = CLng(67108864)
m_l2Power(27) = CLng(134217728)
m_l2Power(28) = CLng(268435456)
m_l2Power(29) = CLng(536870912)
m_l2Power(30) = CLng(1073741824)

Dim x
Dim k
Dim AA
Dim BB
Dim CC
Dim DD
Dim a
Dim b
Dim c
Dim d
Const S11 = 7
Const S12 = 12
Const S13 = 17
Const S14 = 22
Const S21 = 5
Const S22 = 9
Const S23 = 14
Const S24 = 20
Const S31 = 4
Const S32 = 11
Const S33 = 16
Const S34 = 23
Const S41 = 6
Const S42 = 10
Const S43 = 15
Const S44 = 21
x = ConvertToWordArray(sMessage)
a = &H67452301
b = &HEFCDAB89
c = &H98BADCFE
d = &H10325476
For k = 0 To UBound(x) Step 16
AA = a
BB = b
CC = c
DD = d
md5_FF a, b, c, d, x(k + 0), S11, &HD76AA478
md5_FF d, a, b, c, x(k + 1), S12, &HE8C7B756
md5_FF c, d, a, b, x(k + 2), S13, &H242070DB
md5_FF b, c, d, a, x(k + 3), S14, &HC1BDCEEE
md5_FF a, b, c, d, x(k + 4), S11, &HF57C0FAF
md5_FF d, a, b, c, x(k + 5), S12, &H4787C62A
md5_FF c, d, a, b, x(k + 6), S13, &HA8304613
md5_FF b, c, d, a, x(k + 7), S14, &HFD469501
md5_FF a, b, c, d, x(k + 8), S11, &H698098D8
md5_FF d, a, b, c, x(k + 9), S12, &H8B44F7AF
md5_FF c, d, a, b, x(k + 10), S13, &HFFFF5BB1
md5_FF b, c, d, a, x(k + 11), S14, &H895CD7BE
md5_FF a, b, c, d, x(k + 12), S11, &H6B901122
md5_FF d, a, b, c, x(k + 13), S12, &HFD987193
md5_FF c, d, a, b, x(k + 14), S13, &HA679438E
md5_FF b, c, d, a, x(k + 15), S14, &H49B40821
md5_GG a, b, c, d, x(k + 1), S21, &HF61E2562
md5_GG d, a, b, c, x(k + 6), S22, &HC040B340
md5_GG c, d, a, b, x(k + 11), S23, &H265E5A51
md5_GG b, c, d, a, x(k + 0), S24, &HE9B6C7AA
md5_GG a, b, c, d, x(k + 5), S21, &HD62F105D
md5_GG d, a, b, c, x(k + 10), S22, &H2441453
md5_GG c, d, a, b, x(k + 15), S23, &HD8A1E681
md5_GG b, c, d, a, x(k + 4), S24, &HE7D3FBC8
md5_GG a, b, c, d, x(k + 9), S21, &H21E1CDE6
md5_GG d, a, b, c, x(k + 14), S22, &HC33707D6
md5_GG c, d, a, b, x(k + 3), S23, &HF4D50D87
md5_GG b, c, d, a, x(k + 8), S24, &H455A14ED
md5_GG a, b, c, d, x(k + 13), S21, &HA9E3E905
md5_GG d, a, b, c, x(k + 2), S22, &HFCEFA3F8
md5_GG c, d, a, b, x(k + 7), S23, &H676F02D9
md5_GG b, c, d, a, x(k + 12), S24, &H8D2A4C8A
md5_HH a, b, c, d, x(k + 5), S31, &HFFFA3942
md5_HH d, a, b, c, x(k + 8), S32, &H8771F681
md5_HH c, d, a, b, x(k + 11), S33, &H6D9D6122
md5_HH b, c, d, a, x(k + 14), S34, &HFDE5380C
md5_HH a, b, c, d, x(k + 1), S31, &HA4BEEA44
md5_HH d, a, b, c, x(k + 4), S32, &H4BDECFA9
md5_HH c, d, a, b, x(k + 7), S33, &HF6BB4B60
md5_HH b, c, d, a, x(k + 10), S34, &HBEBFBC70
md5_HH a, b, c, d, x(k + 13), S31, &H289B7EC6
md5_HH d, a, b, c, x(k + 0), S32, &HEAA127FA
md5_HH c, d, a, b, x(k + 3), S33, &HD4EF3085
md5_HH b, c, d, a, x(k + 6), S34, &H4881D05
md5_HH a, b, c, d, x(k + 9), S31, &HD9D4D039
md5_HH d, a, b, c, x(k + 12), S32, &HE6DB99E5
md5_HH c, d, a, b, x(k + 15), S33, &H1FA27CF8
md5_HH b, c, d, a, x(k + 2), S34, &HC4AC5665
md5_II a, b, c, d, x(k + 0), S41, &HF4292244
md5_II d, a, b, c, x(k + 7), S42, &H432AFF97
md5_II c, d, a, b, x(k + 14), S43, &HAB9423A7
md5_II b, c, d, a, x(k + 5), S44, &HFC93A039
md5_II a, b, c, d, x(k + 12), S41, &H655B59C3
md5_II d, a, b, c, x(k + 3), S42, &H8F0CCC92
md5_II c, d, a, b, x(k + 10), S43, &HFFEFF47D
md5_II b, c, d, a, x(k + 1), S44, &H85845DD1
md5_II a, b, c, d, x(k + 8), S41, &H6FA87E4F
md5_II d, a, b, c, x(k + 15), S42, &HFE2CE6E0
md5_II c, d, a, b, x(k + 6), S43, &HA3014314
md5_II b, c, d, a, x(k + 13), S44, &H4E0811A1
md5_II a, b, c, d, x(k + 4), S41, &HF7537E82
md5_II d, a, b, c, x(k + 11), S42, &HBD3AF235
md5_II c, d, a, b, x(k + 2), S43, &H2AD7D2BB
md5_II b, c, d, a, x(k + 9), S44, &HEB86D391
a = AddUnsigned(a, AA)
b = AddUnsigned(b, BB)
c = AddUnsigned(c, CC)
d = AddUnsigned(d, DD)
Next
MD5 = LCase(WordToHex(a) &
WordToHex(b) &
WordToHex(c) &
WordToHex(d))
' MD5=LCase(WordToHex(b) &
WordToHex(c)) 'I crop this to fit 16byte database password :D
End Function
Response.Write "123456的加密结果为[" &
md5 ("123456") &
"]"
%>
 
http://www.csdn.net/Dev/Delphi/vcl/vcltools/
 
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
str1, str2: string;
begin
IdCoderMD51.Reset;
IdCoderMD51.AutoCompleteInput := True;
str1 := IdCoderMD51.CodeString('123456');
Delete(str1, 1, 2);
str2 := '';
for i := 0 to Length(str1) do
begin
str2 := str2 + LowerCase(IntToHex(BYTE(str1), 2));
end;

edit2.Text := str2;
end;

可以这样使用。
但是和asp下计算的算法得到的结果不一样。
不知道为什么。
 
楼上的兄弟:你只给出用法有什么用啊。
另外,如果你有DELPHI的代码,并且得到的结果与我上面的ASP代码不同的话,
一定是你的代码不对。上面那段ASP代码是我从一个论坛的源代码里截取的,
并且我也有DELPHI的源代码,两者得出的结果是一样的。
我至所以不贴DELPHI的源代码,是有意想让读者费些力气,毕竞MD5算法不是实现
某个系统的关键(密码破解程序除外),将ASP代码转换成DELPHI代码有利于读者
更深刻地理解MD5算法。至于给分才给代码,是开玩笑而己。
 
Re:happyzxj
给我MD5的DELPHI源代码,给你100分。
 
http://www.neweasier.com/vcl.html?class=35
多的是
 
才给100分啊,不过,分多分少无所谓,还是给你吧。
ftp://zxj.vicp.net/md5
每天6:00-22:00开机,但有时(不经常)会因为各种原因而不能开机。
或者你给我你的E-MAIL
1735
 
/************************************************
MD5 算法的Java Bean
@author:Topcat Tuppin
Last Modified:10,Mar,2001
*************************************************/
package beartool;
import java.lang.reflect.*;
/*************************************************
md5 類實現了RSA Data Security, Inc.在提交給IETF
的RFC1321中的MD5 message-digest 算法。
*************************************************/
public class MD5 {
/* 下面這些S11-S44實際上是一個4*4的矩陣,在原始的C實現中是用#define 實現的,
這裡把它們實現成為static final是表示了隻讀,切能在同一個進程空間內的多個
Instance間共享*/
static final int S11 = 7;
static final int S12 = 12;
static final int S13 = 17;
static final int S14 = 22;
static final int S21 = 5;
static final int S22 = 9;
static final int S23 = 14;
static final int S24 = 20;
static final int S31 = 4;
static final int S32 = 11;
static final int S33 = 16;
static final int S34 = 23;
static final int S41 = 6;
static final int S42 = 10;
static final int S43 = 15;
static final int S44 = 21;
static final byte[] PADDING = { -128, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 下面的三個成員是MD5計算過程中用到的3個核心數據,在原始的C實現中
被定義到MD5_CTX結構中

*/
private long[] state = new long[4];
// state (ABCD)
private long[] count = new long[2];
// number of bits, modulo 2^64 (lsb first)
private byte[] buffer = new byte[64];
// input buffer

/* digestHexStr是MD5的唯一一個公共成員,是最新一次計算結果的
16進制ASCII表示.
*/
public String digestHexStr;

/* digest,是最新一次計算結果的2進制內部表示,表示128bit的MD5值.
*/
private byte[] digest = new byte[16];

/*
getMD5ofStr是類MD5最主要的公共方法,入口參數是你想要進行MD5變換的字符串
返回的是變換完的結果,這個結果是從公共成員digestHexStr取得的﹒
*/
public String getMD5ofStr(String inbuf) {
md5Init();
md5Update(inbuf.getBytes(), inbuf.length());
md5Final();
digestHexStr = "";
for (int i = 0;
i < 16;
i++) {
digestHexStr += byteHEX(digest);
}
return digestHexStr;
}
// 這是MD5這個類的標準構造函數,JavaBean要求有一個public的並且沒有參數的構造函數
public MD5() {
md5Init();
return;
}


/* md5Init是一個初始化函數,初始化核心變量,裝入標準的幻數 */
private void md5Init() {
count[0] = 0L;
count[1] = 0L;
///* Load magic initialization constants.
state[0] = 0x67452301L;
state[1] = 0xefcdab89L;
state[2] = 0x98badcfeL;
state[3] = 0x10325476L;
return;
}
/* F, G, H ,I 是4個基本的MD5函數,在原始的MD5的C實現中,由於它們是
簡單的位運算,可能出於效率的考慮把它們實現成了宏,在java中,我們把它們
實現成了private方法,名字保持了原來C中的。 */
private long F(long x, long y, long z) {
return (x &
y) | ((~x) &
z);
}
private long G(long x, long y, long z) {
return (x &
z) | (y &
(~z));
}
private long H(long x, long y, long z) {
return x ^ y ^ z;
}
private long I(long x, long y, long z) {
return y ^ (x | (~z));
}

/*
FF,GG,HH和II將調用F,G,H,I進行近一步變換
FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
Rotation is separate from addition to prevent recomputation.
*/
private long FF(long a, long b, long c, long d, long x, long s,
long ac) {
a += F (b, c, d) + x + ac;
a = ((int) a << s) | ((int) a >>> (32 - s));
a += b;
return a;
}
private long GG(long a, long b, long c, long d, long x, long s,
long ac) {
a += G (b, c, d) + x + ac;
a = ((int) a << s) | ((int) a >>> (32 - s));
a += b;
return a;
}
private long HH(long a, long b, long c, long d, long x, long s,
long ac) {
a += H (b, c, d) + x + ac;
a = ((int) a << s) | ((int) a >>> (32 - s));
a += b;
return a;
}
private long II(long a, long b, long c, long d, long x, long s,
long ac) {
a += I (b, c, d) + x + ac;
a = ((int) a << s) | ((int) a >>> (32 - s));
a += b;
return a;
}
/*
md5Update是MD5的主計算過程,inbuf是要變換的字節串,inputlen是長度,這個
函數由getMD5ofStr調用,調用之前需要調用md5init,因此把它設計成private的
*/
private void md5Update(byte[] inbuf, int inputLen) {
int i, index, partLen;
byte[] block = new byte[64];
index = (int)(count[0] >>> 3) &
0x3F;
// /* Update number of bits */
if ((count[0] += (inputLen << 3)) < (inputLen << 3))
count[1]++;
count[1] += (inputLen >>> 29);
partLen = 64 - index;
// Transform as many times as possible.
if (inputLen >= partLen) {
md5Memcpy(buffer, inbuf, index, 0, partLen);
md5Transform(buffer);
for (i = partLen;
i + 63 < inputLen;
i += 64) {
md5Memcpy(block, inbuf, 0, i, 64);
md5Transform (block);
}
index = 0;
} else

i = 0;
///* Buffer remaining input */
md5Memcpy(buffer, inbuf, index, i, inputLen - i);
}

/*
md5Final整理和填寫輸出結果
*/
private void md5Final () {
byte[] bits = new byte[8];
int index, padLen;
///* Save number of bits */
Encode (bits, count, 8);
///* Pad out to 56 mod 64.
index = (int)(count[0] >>> 3) &
0x3f;
padLen = (index < 56) ? (56 - index) : (120 - index);
md5Update (PADDING, padLen);
///* Append length (before padding) */
md5Update(bits, 8);
///* Store state in digest */
Encode (digest, state, 16);
}

/* md5Memcpy是一個內部使用的byte數組的塊拷貝函數,從input的inpos開始把len長度的
字節拷貝到output的outpos位置開始
*/
private void md5Memcpy (byte[] output, byte[] input,
int outpos, int inpos, int len)
{
int i;
for (i = 0;
i < len;
i++)
output[outpos + i] = input[inpos + i];
}

/*
md5Transform是MD5核心變換程序,有md5Update調用,block是分塊的原始字節
*/
private void md5Transform (byte block[]) {
long a = state[0], b = state[1], c = state[2], d = state[3];
long[] x = new long[16];
Decode (x, block, 64);
/* Round 1 */
a = FF (a, b, c, d, x[0], S11, 0xd76aa478L);
/* 1 */
d = FF (d, a, b, c, x[1], S12, 0xe8c7b756L);
/* 2 */
c = FF (c, d, a, b, x[2], S13, 0x242070dbL);
/* 3 */
b = FF (b, c, d, a, x[3], S14, 0xc1bdceeeL);
/* 4 */
a = FF (a, b, c, d, x[4], S11, 0xf57c0fafL);
/* 5 */
d = FF (d, a, b, c, x[5], S12, 0x4787c62aL);
/* 6 */
c = FF (c, d, a, b, x[6], S13, 0xa8304613L);
/* 7 */
b = FF (b, c, d, a, x[7], S14, 0xfd469501L);
/* 8 */
a = FF (a, b, c, d, x[8], S11, 0x698098d8L);
/* 9 */
d = FF (d, a, b, c, x[9], S12, 0x8b44f7afL);
/* 10 */
c = FF (c, d, a, b, x[10], S13, 0xffff5bb1L);
/* 11 */
b = FF (b, c, d, a, x[11], S14, 0x895cd7beL);
/* 12 */
a = FF (a, b, c, d, x[12], S11, 0x6b901122L);
/* 13 */
d = FF (d, a, b, c, x[13], S12, 0xfd987193L);
/* 14 */
c = FF (c, d, a, b, x[14], S13, 0xa679438eL);
/* 15 */
b = FF (b, c, d, a, x[15], S14, 0x49b40821L);
/* 16 */
/* Round 2 */
a = GG (a, b, c, d, x[1], S21, 0xf61e2562L);
/* 17 */
d = GG (d, a, b, c, x[6], S22, 0xc040b340L);
/* 18 */
c = GG (c, d, a, b, x[11], S23, 0x265e5a51L);
/* 19 */
b = GG (b, c, d, a, x[0], S24, 0xe9b6c7aaL);
/* 20 */
a = GG (a, b, c, d, x[5], S21, 0xd62f105dL);
/* 21 */
d = GG (d, a, b, c, x[10], S22, 0x2441453L);
/* 22 */
c = GG (c, d, a, b, x[15], S23, 0xd8a1e681L);
/* 23 */
b = GG (b, c, d, a, x[4], S24, 0xe7d3fbc8L);
/* 24 */
a = GG (a, b, c, d, x[9], S21, 0x21e1cde6L);
/* 25 */
d = GG (d, a, b, c, x[14], S22, 0xc33707d6L);
/* 26 */
c = GG (c, d, a, b, x[3], S23, 0xf4d50d87L);
/* 27 */
b = GG (b, c, d, a, x[8], S24, 0x455a14edL);
/* 28 */
a = GG (a, b, c, d, x[13], S21, 0xa9e3e905L);
/* 29 */
d = GG (d, a, b, c, x[2], S22, 0xfcefa3f8L);
/* 30 */
c = GG (c, d, a, b, x[7], S23, 0x676f02d9L);
/* 31 */
b = GG (b, c, d, a, x[12], S24, 0x8d2a4c8aL);
/* 32 */
/* Round 3 */
a = HH (a, b, c, d, x[5], S31, 0xfffa3942L);
/* 33 */
d = HH (d, a, b, c, x[8], S32, 0x8771f681L);
/* 34 */
c = HH (c, d, a, b, x[11], S33, 0x6d9d6122L);
/* 35 */
b = HH (b, c, d, a, x[14], S34, 0xfde5380cL);
/* 36 */
a = HH (a, b, c, d, x[1], S31, 0xa4beea44L);
/* 37 */
d = HH (d, a, b, c, x[4], S32, 0x4bdecfa9L);
/* 38 */
c = HH (c, d, a, b, x[7], S33, 0xf6bb4b60L);
/* 39 */
b = HH (b, c, d, a, x[10], S34, 0xbebfbc70L);
/* 40 */
a = HH (a, b, c, d, x[13], S31, 0x289b7ec6L);
/* 41 */
d = HH (d, a, b, c, x[0], S32, 0xeaa127faL);
/* 42 */
c = HH (c, d, a, b, x[3], S33, 0xd4ef3085L);
/* 43 */
b = HH (b, c, d, a, x[6], S34, 0x4881d05L);
/* 44 */
a = HH (a, b, c, d, x[9], S31, 0xd9d4d039L);
/* 45 */
d = HH (d, a, b, c, x[12], S32, 0xe6db99e5L);
/* 46 */
c = HH (c, d, a, b, x[15], S33, 0x1fa27cf8L);
/* 47 */
b = HH (b, c, d, a, x[2], S34, 0xc4ac5665L);
/* 48 */
/* Round 4 */
a = II (a, b, c, d, x[0], S41, 0xf4292244L);
/* 49 */
d = II (d, a, b, c, x[7], S42, 0x432aff97L);
/* 50 */
c = II (c, d, a, b, x[14], S43, 0xab9423a7L);
/* 51 */
b = II (b, c, d, a, x[5], S44, 0xfc93a039L);
/* 52 */
a = II (a, b, c, d, x[12], S41, 0x655b59c3L);
/* 53 */
d = II (d, a, b, c, x[3], S42, 0x8f0ccc92L);
/* 54 */
c = II (c, d, a, b, x[10], S43, 0xffeff47dL);
/* 55 */
b = II (b, c, d, a, x[1], S44, 0x85845dd1L);
/* 56 */
a = II (a, b, c, d, x[8], S41, 0x6fa87e4fL);
/* 57 */
d = II (d, a, b, c, x[15], S42, 0xfe2ce6e0L);
/* 58 */
c = II (c, d, a, b, x[6], S43, 0xa3014314L);
/* 59 */
b = II (b, c, d, a, x[13], S44, 0x4e0811a1L);
/* 60 */
a = II (a, b, c, d, x[4], S41, 0xf7537e82L);
/* 61 */
d = II (d, a, b, c, x[11], S42, 0xbd3af235L);
/* 62 */
c = II (c, d, a, b, x[2], S43, 0x2ad7d2bbL);
/* 63 */
b = II (b, c, d, a, x[9], S44, 0xeb86d391L);
/* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
}

/*Encode把long數組按順序拆成byte數組,因為java的long類型是64bit的,
隻拆低32bit,以適應原始C實現的用途
*/
private void Encode (byte[] output, long[] input, int len) {
int i, j;
for (i = 0, j = 0;
j < len;
i++, j += 4) {
output[j] = (byte)(input &
0xffL);
output[j + 1] = (byte)((input >>> 8) &
0xffL);
output[j + 2] = (byte)((input >>> 16) &
0xffL);
output[j + 3] = (byte)((input >>> 24) &
0xffL);
}
}
/*Decode把byte數組按順序合成成long數組,因為java的long類型是64bit的,
隻合成低32bit,高32bit清零,以適應原始C實現的用途
*/
private void Decode (long[] output, byte[] input, int len) {
int i, j;

for (i = 0, j = 0;
j < len;
i++, j += 4)
output = b2iu(input[j]) |
(b2iu(input[j + 1]) << 8) |
(b2iu(input[j + 2]) << 16) |
(b2iu(input[j + 3]) << 24);
return;
}

/*
b2iu是我寫的一個把byte按照不考慮正負號的原則的 升位 程序,因為java沒有unsigned運算
*/
public static long b2iu(byte b) {
return b < 0 ? b &
0x7F + 128 : b;
}

/*byteHEX(),用來把一個byte類型的數轉換成十六進制的ASCII表示,
因為java中的byte的toString無法實現這一點,我們又沒有C語言中的
sprintf(outbuf,"%02X",ib)
*/
public static String byteHEX(byte ib) {
char[] Digit = { '0','1','2','3','4','5','6','7','8','9',
'A','B','C','D','E','F' };
char [] ob = new char[2];
ob[0] = Digit[(ib >>> 4) &
0X0F];
ob[1] = Digit[ib &
0X0F];
String s = new String(ob);
return s;
}
public static void main(String args[]) {

MD5 m = new MD5();
if (Array.getLength(args) == 0) { //如果沒有參數,執行標準的Test Suite

System.out.println("MD5 Test suite:");
System.out.println("MD5(/"/"):"+m.getMD5ofStr(""));
System.out.println("MD5(/"a/"):"+m.getMD5ofStr("a"));
System.out.println("MD5(/"abc/"):"+m.getMD5ofStr("abc"));
System.out.println("MD5(/"message digest/"):"+m.getMD5ofStr("message digest"));
System.out.println("MD5(/"abcdefghijklmnopqrstuvwxyz/"):"+
m.getMD5ofStr("abcdefghijklmnopqrstuvwxyz"));
System.out.println("MD5(/"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/"):"+
m.getMD5ofStr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"));
}
else

System.out.println("MD5(" + args[0] + ")=" + m.getMD5ofStr(args[0]));


}
}
 
我有For Delphi6的MD5函数源代码,只需调用该Pas中的一个函数就行了
function MD5_Hash(const InputString: string): string
如果你要请留下Email我发给你。
 
在这里 http://www.fichtner.net/delphi/md5/ 下载
1、 MD5String、MD5File、MD5Print、MD5Match这四个函数是供调用的。其他是用来辅助这几个函数的子函数。
2、MD5String为加密字符串。
3、MD5File为加密这个文件。
4、MD5Print是将加密后的密文转换成字符串。
5、MD5Match是用来比较密文是否一致。
加密字符串aaa MD5String('aaa')
将加密后的aaa显示出来 MD5Print(MD5String('aaa'))
比较两次密文是否一致: MD5Match(MD5String('第一次明文'),MD5String('第二次输入的明文'))
如果要用这个单元,只需要在项目中添加这个文件,uses md5,就可以了
delphi 4以上版本都可以。

 
to:叮叮当当
给我一份MD5算法的Delphi源代码?
sz-sunding@163.net
 
http://www.cityinthesky.co.uk/
上面有一个控件包下载,里面包含了加密的一系列算法。
===============================================================================
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
= DCPcrypt Cryptographic Component Library v2 Beta 2 =
= Copyright (c) 1999-2002 David Barton =
= http://www.cityinthesky.co.uk/ =
= crypto@cityinthesky.co.uk =
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Introduction:
DCPcrypt is a collection of cryptographic components for the Borland
Delphi(tm), C++ Builder(tm) and Kylix(tm) programming languages. The
supported versions are Delphi 4, 5 and 6, C++ Builder (3?), 4, 5, 6
and Kylix 1 (untested) and 2.
The idea behind DCPcrypt is that it should be possible to "drop in"
any algorithm implementation to replace another with minimum or no
code changes. To aid in this goal all cryptographic components are
descended from one of several base classes, TDCP_cipher for encryption
algorithms and TDCP_hash for message digest algorithms.
DCPcrypt is open source software (released under the MIT license) and
as such there is no charge for inclusion in other software. However, I
am currently a student and if you are making money from my software I
would really appreciate a do
nation of some sort, whether financial or
a license for the software you develop (or if anyone wants to sponsor
a Mathematical Modelling (Masters) student for their final year...).
Please note THIS IS NOT COMPULSORY IN ANY WAY. See
http://www.cityinthesky.co.uk/cryptography.html for details on
financial do
nations.
This software is OSI Certified Open Source Software.
OSI Certified is a certification mark of the Open Source Initiative.
If you maintain a website then
a link to my page at
http://www.cityinthesky.co.uk/ would be great!

What's New:
Changes since DCPcrypt v2 Beta 1 include
* Renamed source code files for hashes and ciphers to DCPxxx.pas

* Change the format of Cipher.InitStr so that the hash algorithm
used to generate the key is explicitly specified. In order to
get the same functionality as before, use TDCP_sha1.
e.g. Cipher.InitStr('Hello World',TDCP_sha1);
* Block ciphers are now inherited from an intermediate component
that implements the block size specific chaining mode encryption
routines.
* Remove the internal component registration, it was more hassle
than it was worth. If there is a demand for this to be put back
then
I might...
* Added the full range of operation modes for Haval. By changing
the defines at the top of DCPhaval.pas you can specify the
number of passes and the output hash size.

* Added the Tiger hash algorithm (192bit digest).

* Changed the name of the file containing TDCP_ripemd160 for
consistency to DCPripemd160 from DCPrmd160.

* GOST no longer appears on the component palette pending verifying
what the actual standard is (the code is still included however).
* Added the RipeMD-128 hash algorithm (128bit digest).

* Added the Serpent block cipher (AES finalist).

* Added the SHA-256,384,512 hash algorithms (256, 384, 512bit digest
respectively).
* Added CTR chaining mode to all block ciphers.


Installation:
Delphi: Open the appropriate package, DCPdelphiX.dpk where X is
your version of Delphi (either 4, 5 or 6). then
press the
install button.
C++ Builder: Create a new design time package and add all the .pas
files from the DCPcrypt2.zip archive including all those
in the Ciphers and Hashes subdirectories. then
press the
install button.
Kylix: Open the DCPkylix.dpk package and then
press the install
button (note: Kylix 1 users may need to create a new
package as with C++ Builder as this is a Kylix 2 package).
You may need to add the directory containing DCPcrypt (and the Ciphers
and Hashes subdirectories) to your library search path (found under
Environment Options).
Once installed you will find two extra pages of components on your
component palette, namely DCPciphers and DCPhashes. You can now place
these components onto the form of your application to start using the
algorithms.

Usage:
See the main html do
cumentation in the do
cs subdirectory.

Contact:
I appreciate knowing what DCPcrypt is being used for and also if you
have any queries or bug reports please email me at crypto@cityinthesky.co.uk.

DCPcrypt is copyrighted (c) 1999-2002 David Barton.
All trademarks are property of their respective owners.
 
delphi的MD5代码
unit md5;
// -----------------------------------------------------------------------------------------------
INTERFACE
// -----------------------------------------------------------------------------------------------
uses
Windows;
type
MD5Count = array[0..1] of DWORD;
MD5State = array[0..3] of DWORD;
MD5Block = array[0..15] of DWORD;
MD5CBits = array[0..7] of byte;
MD5Digest = array[0..15] of byte;
MD5Buffer = array[0..63] of byte;
MD5Context = record
State: MD5State;
Count: MD5Count;
Buffer: MD5Buffer;
end;

procedure MD5Init(var Context: MD5Context);
procedure MD5Update(var Context: MD5Context;
Input: pChar;
Length: longword);
procedure MD5Final(var Context: MD5Context;
var Digest: MD5Digest);
function MD5String(M: string): MD5Digest;
function MD5File(N: string): MD5Digest;
function MD5Print(D: MD5Digest): string;
function MD5Match(D1, D2: MD5Digest): boolean;
// -----------------------------------------------------------------------------------------------
IMPLEMENTATION
// -----------------------------------------------------------------------------------------------
var
PADDING: MD5Buffer = (
$80, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00
);
function F(x, y, z: DWORD): DWORD;
begin
Result := (x and y) or ((not x) and z);
end;

function G(x, y, z: DWORD): DWORD;
begin
Result := (x and z) or (y and (not z));
end;

function H(x, y, z: DWORD): DWORD;
begin
Result := x xor y xor z;
end;

function I(x, y, z: DWORD): DWORD;
begin
Result := y xor (x or (not z));
end;

procedure rot(var x: DWORD;
n: BYTE);
begin
x := (x shl n) or (x shr (32 - n));
end;

procedure FF(var a: DWORD;
b, c, d, x: DWORD;
s: BYTE;
ac: DWORD);
begin
inc(a, F(b, c, d) + x + ac);
rot(a, s);
inc(a, b);
end;

procedure GG(var a: DWORD;
b, c, d, x: DWORD;
s: BYTE;
ac: DWORD);
begin
inc(a, G(b, c, d) + x + ac);
rot(a, s);
inc(a, b);
end;

procedure HH(var a: DWORD;
b, c, d, x: DWORD;
s: BYTE;
ac: DWORD);
begin
inc(a, H(b, c, d) + x + ac);
rot(a, s);
inc(a, b);
end;

procedure II(var a: DWORD;
b, c, d, x: DWORD;
s: BYTE;
ac: DWORD);
begin
inc(a, I(b, c, d) + x + ac);
rot(a, s);
inc(a, b);
end;

// -----------------------------------------------------------------------------------------------
// Encode Count bytes at Source into (Count / 4) DWORDs at Target
procedure Encode(Source, Target: pointer;
Count: longword);
var
S: PByte;
T: PDWORD;
I: longword;
begin
S := Source;
T := Target;
for I := 1 to Count div 4 do
begin
T^ := S^;
inc(S);
T^ := T^ or (S^ shl 8);
inc(S);
T^ := T^ or (S^ shl 16);
inc(S);
T^ := T^ or (S^ shl 24);
inc(S);
inc(T);
end;
end;

// Decode Count DWORDs at Source into (Count * 4) Bytes at Target
procedure Decode(Source, Target: pointer;
Count: longword);
var
S: PDWORD;
T: PByte;
I: longword;
begin
S := Source;
T := Target;
for I := 1 to Count do
begin
T^ := S^ and $ff;
inc(T);
T^ := (S^ shr 8) and $ff;
inc(T);
T^ := (S^ shr 16) and $ff;
inc(T);
T^ := (S^ shr 24) and $ff;
inc(T);
inc(S);
end;
end;

// Transform State according to first 64 bytes at Buffer
procedure Transform(Buffer: pointer;
var State: MD5State);
var
a, b, c, d: DWORD;
Block: MD5Block;
begin
Encode(Buffer, @Block, 64);
a := State[0];
b := State[1];
c := State[2];
d := State[3];
FF (a, b, c, d, Block[ 0], 7, $d76aa478);
FF (d, a, b, c, Block[ 1], 12, $e8c7b756);
FF (c, d, a, b, Block[ 2], 17, $242070db);
FF (b, c, d, a, Block[ 3], 22, $c1bdceee);
FF (a, b, c, d, Block[ 4], 7, $f57c0faf);
FF (d, a, b, c, Block[ 5], 12, $4787c62a);
FF (c, d, a, b, Block[ 6], 17, $a8304613);
FF (b, c, d, a, Block[ 7], 22, $fd469501);
FF (a, b, c, d, Block[ 8], 7, $698098d8);
FF (d, a, b, c, Block[ 9], 12, $8b44f7af);
FF (c, d, a, b, Block[10], 17, $ffff5bb1);
FF (b, c, d, a, Block[11], 22, $895cd7be);
FF (a, b, c, d, Block[12], 7, $6b901122);
FF (d, a, b, c, Block[13], 12, $fd987193);
FF (c, d, a, b, Block[14], 17, $a679438e);
FF (b, c, d, a, Block[15], 22, $49b40821);
GG (a, b, c, d, Block[ 1], 5, $f61e2562);
GG (d, a, b, c, Block[ 6], 9, $c040b340);
GG (c, d, a, b, Block[11], 14, $265e5a51);
GG (b, c, d, a, Block[ 0], 20, $e9b6c7aa);
GG (a, b, c, d, Block[ 5], 5, $d62f105d);
GG (d, a, b, c, Block[10], 9, $2441453);
GG (c, d, a, b, Block[15], 14, $d8a1e681);
GG (b, c, d, a, Block[ 4], 20, $e7d3fbc8);
GG (a, b, c, d, Block[ 9], 5, $21e1cde6);
GG (d, a, b, c, Block[14], 9, $c33707d6);
GG (c, d, a, b, Block[ 3], 14, $f4d50d87);
GG (b, c, d, a, Block[ 8], 20, $455a14ed);
GG (a, b, c, d, Block[13], 5, $a9e3e905);
GG (d, a, b, c, Block[ 2], 9, $fcefa3f8);
GG (c, d, a, b, Block[ 7], 14, $676f02d9);
GG (b, c, d, a, Block[12], 20, $8d2a4c8a);
HH (a, b, c, d, Block[ 5], 4, $fffa3942);
HH (d, a, b, c, Block[ 8], 11, $8771f681);
HH (c, d, a, b, Block[11], 16, $6d9d6122);
HH (b, c, d, a, Block[14], 23, $fde5380c);
HH (a, b, c, d, Block[ 1], 4, $a4beea44);
HH (d, a, b, c, Block[ 4], 11, $4bdecfa9);
HH (c, d, a, b, Block[ 7], 16, $f6bb4b60);
HH (b, c, d, a, Block[10], 23, $bebfbc70);
HH (a, b, c, d, Block[13], 4, $289b7ec6);
HH (d, a, b, c, Block[ 0], 11, $eaa127fa);
HH (c, d, a, b, Block[ 3], 16, $d4ef3085);
HH (b, c, d, a, Block[ 6], 23, $4881d05);
HH (a, b, c, d, Block[ 9], 4, $d9d4d039);
HH (d, a, b, c, Block[12], 11, $e6db99e5);
HH (c, d, a, b, Block[15], 16, $1fa27cf8);
HH (b, c, d, a, Block[ 2], 23, $c4ac5665);
II (a, b, c, d, Block[ 0], 6, $f4292244);
II (d, a, b, c, Block[ 7], 10, $432aff97);
II (c, d, a, b, Block[14], 15, $ab9423a7);
II (b, c, d, a, Block[ 5], 21, $fc93a039);
II (a, b, c, d, Block[12], 6, $655b59c3);
II (d, a, b, c, Block[ 3], 10, $8f0ccc92);
II (c, d, a, b, Block[10], 15, $ffeff47d);
II (b, c, d, a, Block[ 1], 21, $85845dd1);
II (a, b, c, d, Block[ 8], 6, $6fa87e4f);
II (d, a, b, c, Block[15], 10, $fe2ce6e0);
II (c, d, a, b, Block[ 6], 15, $a3014314);
II (b, c, d, a, Block[13], 21, $4e0811a1);
II (a, b, c, d, Block[ 4], 6, $f7537e82);
II (d, a, b, c, Block[11], 10, $bd3af235);
II (c, d, a, b, Block[ 2], 15, $2ad7d2bb);
II (b, c, d, a, Block[ 9], 21, $eb86d391);
inc(State[0], a);
inc(State[1], b);
inc(State[2], c);
inc(State[3], d);
end;

// -----------------------------------------------------------------------------------------------
// Initialize given Context
procedure MD5Init(var Context: MD5Context);
begin
with Context do
begin
State[0] := $67452301;
State[1] := $efcdab89;
State[2] := $98badcfe;
State[3] := $10325476;
Count[0] := 0;
Count[1] := 0;
ZeroMemory(@Buffer, SizeOf(MD5Buffer));
end;
end;

// Update given Context to include Length bytes of Input
procedure MD5Update(var Context: MD5Context;
Input: pChar;
Length: longword);
var
Index: longword;
PartLen: longword;
I: longword;
begin
with Context do
begin
Index := (Count[0] shr 3) and $3f;
inc(Count[0], Length shl 3);
if Count[0] < (Length shl 3) then
inc(Count[1]);
inc(Count[1], Length shr 29);
end;
PartLen := 64 - Index;
if Length >= PartLen then
begin
CopyMemory(@Context.Buffer[Index], Input, PartLen);
Transform(@Context.Buffer, Context.State);
I := PartLen;
while I + 63 < Length do
begin
Transform(@Input, Context.State);
inc(I, 64);
end;
Index := 0;
end else
I := 0;
CopyMemory(@Context.Buffer[Index], @Input, Length - I);
end;

// Finalize given Context, create Digest and zeroize Context
procedure MD5Final(var Context: MD5Context;
var Digest: MD5Digest);
var
Bits: MD5CBits;
Index: longword;
PadLen: longword;
begin
Decode(@Context.Count, @Bits, 2);
Index := (Context.Count[0] shr 3) and $3f;
if Index < 56 then
PadLen := 56 - Index else
PadLen := 120 - Index;
MD5Update(Context, @PADDING, PadLen);
MD5Update(Context, @Bits, 8);
Decode(@Context.State, @Digest, 4);
ZeroMemory(@Context, SizeOf(MD5Context));
end;

// -----------------------------------------------------------------------------------------------
// Create digest of given Message
function MD5String(M: string): MD5Digest;
var
Context: MD5Context;
begin
MD5Init(Context);
MD5Update(Context, pChar(M), length(M));
MD5Final(Context, Result);
end;

// Create digest of file with given Name
function MD5File(N: string): MD5Digest;
var
FileHandle: THandle;
MapHandle: THandle;
ViewPointer: pointer;
Context: MD5Context;
begin
MD5Init(Context);
FileHandle := CreateFile(pChar(N), GENERIC_READ, FILE_SHARE_READ or FILE_SHARE_WRITE,
nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_SEQUENTIAL_SCAN, 0);
if FileHandle <> INVALID_HANDLE_VALUE then
try
MapHandle := CreateFileMapping(FileHandle, nil, PAGE_READONLY, 0, 0, nil);
if MapHandle <> 0 then
try
ViewPointer := MapViewOfFile(MapHandle, FILE_MAP_READ, 0, 0, 0);
if ViewPointer <> nil then
try
MD5Update(Context, ViewPointer, GetFileSize(FileHandle, nil));
finally
UnmapViewOfFile(ViewPointer);
end;
finally
CloseHandle(MapHandle);
end;
finally
CloseHandle(FileHandle);
end;
MD5Final(Context, Result);
end;

// Create hex representation of given Digest
function MD5Print(D: MD5Digest): string;
var
I: byte;
const
Digits: array[0..15] of char =
('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
begin
Result := '';
for I := 0 to 15 do
Result := Result + Digits[(D shr 4) and $0f] + Digits[D and $0f];
end;

// -----------------------------------------------------------------------------------------------
// Compare two Digests
function MD5Match(D1, D2: MD5Digest): boolean;
var
I: byte;
begin
I := 0;
Result := TRUE;
while Result and (I < 16) do
begin
Result := D1 = D2;
inc(I);
end;
end;
 
To: kenxy
已发。
楼主怎么?不需要了么?
 
To:叮叮当当
非常感谢,我已收到!
 
在这么多人在吹牛?
谁有DELPHI的MD5反向算法?有种的拿一个出来,这样才算有本事。
 
MD5的逆向算法好像还没问世哦。[8D]
 
后退
顶部