使用方法:
msgbox DigestStrToHexStr("111")
源代码:
-----------剪切线------------------------------------------------------------
Option Explicit
''''/****************************************************************************** '''' * Copyright (C) 2000 by Robert Hubley. * '''' * All rights reserved. * '''' * * '''' * This software is provided ``AS IS'''''''' and any express or implied * '''' * warranties, including, but not limited to, the implied warranties of * '''' * merchantability and fitness for a particular purpose, are disclaimed. * '''' * In no event shall the authors be liable for any direct, indirect, * '''' * incidental, special, exemplary, or consequential damages (including, but * '''' * not limited to, procurement of substitute goods or services; loss of use, * '''' * data, or profits; or business interruption) however caused and on any * '''' * theory of liability, whether in contract, strict liability, or tort * '''' * (including negligence or otherwise) arising in any way out of the use of * '''' * this software, even if advised of the possibility of such damage. * '''' * * '''' ****************************************************************************** '''' '''' CLASS: MD5 '''' '''' DESCRIPTION: '''' This is a class which encapsulates a set of MD5 Message Digest functions. '''' MD5 algorithm produces a 128 bit digital fingerprint (signature) from an '''' dataset of arbitrary length. For details see RFC 1321 (summarized below). '''' This implementation is derived from the RSA Data Security, Inc. MD5 Message-Digest '''' algorithm reference implementation (originally written in C) '''' '''' AUTHOR: '''' Robert M. Hubley 12/1999 '''' '''' '''' NOTES: '''' Network Working Group R. Rivest '''' Request for Comments: 1321 MIT Laboratory for Computer Science '''' and RSA Data Security, Inc. '''' April 1992 '''' '''' '''' The MD5 Message-Digest Algorithm '''' '''' 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 Strin [1] [2] [3] [4] 下一页 [Web开发]ASP.Net中的MD5加密
|