VB中实现MD5加密[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 bucher 的 blog

'      summary
'
'         this document describes the md5 message-digest algorithm. the
'         algorithm takes as input a message of arbitrary length and produces
'         as output a 128-bit "fingerprint" or "message digest" of the input.
'         it is conjectured that it is computationally infeasible to produce
'         two messages having the same message digest, or to produce any
'         message having a given prespecified target message digest. the md5
'         algorithm is intended for digital signature applications, where a
'         large file must be "compressed" in a secure manner before being
'         encrypted with a private (secret) key under a public-key cryptosystem
'         such as rsa.
'
'         the md5 algorithm is designed to be quite fast on 32-bit machines. in
'         addition, the md5 algorithm does not require any large substitution
'         tables; the algorithm can be coded quite compactly.
'
'         the md5 algorithm is an extension of the md4 message-digest algorithm
'         1,2]. md5 is slightly slower than md4, but is more "conservative" in
'         design. md5 was designed because it was felt that md4 was perhaps
'         being adopted for use more quickly than justified by the existing
'         critical review; because md4 was designed to be exceptionally fast,
'         it is "at the edge" in terms of risking successful cryptanalytic
'         attack. md5 backs off a bit, giving up a little in speed for a much
'         greater likelihood of ultimate security. it incorporates some
'         suggestions made by various reviewers, and contains additional
'         optimizations. the md5 algorithm is being placed in the public domain
'         for review and possible adoption as a standard.
'
'         rfc author:
'         ronald l.rivest
'         massachusetts institute of technology
'         laboratory for computer science
'         ne43 -324545    technology square
'         cambridge, ma  02139-1986
'         phone: (617) 253-5880
'         email:    rivest@ theory.lcs.mit.edu
'
'
'
'  change history:
'
'     0.1.0  rmh    1999/12/29      original version
'
'


'=
'= class constants
'=
private const offset_4 = 4294967296#
private const maxint_4 = 2147483647

private const s11 = 7
private const s12 = 12
private const s13 = 17
private const s14 = 22
private const s21 = 5
private const s22 = 9
private const s23 = 14
private const s24 = 20
private const s31 = 4
private const s32 = 11
private const s33 = 16
private const s34 = 23
private const s41 = 6
private const s42 = 10
private const s43 = 15
private const s44 = 21


'=
'= class variables
'=
private state(4) as long
private bytecounter as long
private bytebuffer(63) as byte


'=
'= class properties
'=
property get registera() as string
    registera = state(1)
end property

property get registerb() as string
    registerb = state(2)
end property

property get registerc() as string
    registerc = state(3)
end property

property get registerd() as string
    registerd = state(4)
end property


'=
'= class functions
'=

'
' function to quickly digest a file into a hex string
'

本文关键:MD5,VB6
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top