现在比较流行的MD5的校验算法, 查了一下, 竟然没有VFP的源码?!
可能是没有提到过吧.
希望有能力的大侠能够提供MD5算法的VFP源码, 让我等菜鸟瞻仰瞻仰
期待中……
------解决方案--------------------------------------------------------
**************************************************************
* Md5算法在VFP中的实现
* 调用方法: MD5(要加密的字符串,8) 或 MD5(要加密的字符串,16)
* 第二个参数说明加密位长,8位或16位,默认为8位+
* 转自梅子论坛[mayleelife]
* 梅子VFP论坛 www.meizvfp.com
**************************************************************
FUNCTION LShift(lvalue, iShiftBits)
IF iShiftBits = 0
RETURN lvalue
ELSE
IF iShiftBits = 31
IF BITAND(lvalue , 1) <> 0
RETURN 0x80000000
ELSE
RETURN 0
ENDIF
ENDIF
ENDIF
IF BITAND(lValue, m_l2Power(32 - iShiftBits)) <> 0
RETURN BITOR( (BITAND(lValue , m_lOnBits(32 - (iShiftBits + 1))) * m_l2Power(iShiftBits + 1)) , 0x80000000)
ELSE
RETURN BITAND(lvalue , m_lOnBits(32 - iShiftBits)) * m_l2Power(iShiftBits + 1)
ENDIF
ENDFUNC
FUNCTION RShift(lvalue, iShiftBits)
IF iShiftBits = 0
RETURN lvalue
ELSE
IF iShiftBits = 31
IF BITAND(lvalue , 0x80000000)
RETURN 1
ELSE
RETURN 0
ENDIF
ENDIF
ENDIF
RShift2 = INT(BITAND(lvalue , 0x7FFFFFFE) / m_l2Power(iShiftBits + 1))
IF BITAND(lvalue , 0x80000000) <> 0
RShift2 =BITOR (RShift2 , INT(0x40000000 / m_l2Power(iShiftBits )))
ENDIF
RETURN RShift2
ENDFUNC
FUNCTION RotateLeft(lvalue, iShiftBits)
RETURN BITOR(LShift(lvalue, iShiftBits) ,RShift(lvalue, (32 - iShiftBits)))
ENDFUNC
FUNCTION AddUnsigned(lX, lY)
lX8 = BITAND(lX , 0x80000000)
lY8 = BITAND(lY , 0x80000000)
lX4 = BITAND(lX , 0x40000000)
lY4 = BITAND(lY , 0x40000000)
lResult = BITAND(lX , 0x3FFFFFFF) + BITAND(lY , 0x3FFFFFFF)
IF BITAND(lX4 , lY4) <> 0
lResult = BITXOR(BITXOR(BITXOR(lResult , 0x80000000) , lX8) , lY8)
ELSE
IF BITOR(lX4 , lY4) <> 0
IF BITAND(lResult , 0x40000000) <> 0
lResult = BITXOR(BITXOR(BITXOR(lResult , 0xC0000000) , lX8) , lY8)
ELSE
lResult = BITXOR(BITXOR(BITXOR(lResult , 0x40000000) , lX8) , lY8)
ENDIF
ELSE
lResult = BITXOR(BITXOR( lResult , lX8) , lY8)
ENDIF
ENDIF
RETURN lResult
ENDFUNC
FUNCTION md5_F(x, y, z)
RETURN BITOR(BITAND(x , y) , BITAND(BITNOT(x) , z))
ENDFUNC
FUNCTION md5_G(x, y, z)
RETURN BITOR(BITAND(x , z) , BITAND(y , BITNOT(z)))
ENDFUNC
FUNCTION md5_H(x, y, z)
RETURN BITXOR(BITXOR(x , y) , z)
ENDFUNC
FUNCTION md5_I(x, y, z)
RETURN BITXOR(y , BITOR(x , BITNOT(z)))
ENDFUNC
PROCEDURE 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)
ENDPROC
PROCEDURE 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)
ENDPROC
PROCEDURE 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)
ENDPROC
PROCEDURE md5_II(a, b, c, d, x, s, ac)