⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 md5.h

📁 一个简单的求取文件MD5值的实现文件
💻 H
字号:
//---------------------------------------------------------------------------

#ifndef MD5H
#define MD5H

//---------------------------------------------------------------------------
/******************************************************************************
*     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.                   *
*                                                                                                                                                         *
******************************************************************************

MD5.H   -   header   file   for   MD5C.C

    Port   to   Win32   DLL   by   Robert   Hubley   1/5/2000

    Original   Copyright:  

Copyright   (C)   1991-2,   RSA   Data   Security,   Inc.   Created   1991.   All  
rights   reserved.
   
License   to   copy   and   use   this   software   is   granted   provided   that   it  
is   identified   as   the   "RSA   Data   Security,   Inc.   MD5   Message-Digest  
Algorithm"   in   all   material   mentioning   or   referencing   this   software  
or   this   function.
   
License   is   also   granted   to   make   and   use   derivative   works   provided  
that   such   works   are   identified   as   "derived   from   the   RSA   Data  
Security,   Inc.   MD5   Message-Digest   Algorithm"   in   all   material  
mentioning   or   referencing   the   derived   work.
   
RSA   Data   Security,   Inc.   makes   no   representations   concerning   either  
the   merchantability   of   this   software   or   the   suitability   of   this  
software   for   any   particular   purpose.   It   is   provided   "as   is"  
without   express   or   implied   warranty   of   any   kind.
   
These   notices   must   be   retained   in   any   copies   of   any   part   of   this  
documentation   and/or   software.  
*/  
/******************************************************************************
*     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.                   *  
*                                                                                                                                                         *  
******************************************************************************
*/  
   
/******************************************************************************
*       2002-4-18   Modified   by   Liguangyi.             *  
*       struct   MD5_CTX   ==>   class   MD5_CTX.                     *  
*       Take   off   the   Globals   Functions                                                                                       *
******************************************************************************  
*/

/*   MD5   Class.   */  
class   MD5_CTX
{
public:
MD5_CTX();
virtual   ~MD5_CTX();
void   MD5Update   (   unsigned   char   *input,   unsigned   int   inputLen);
void   MD5Final   (unsigned   char   digest[16]);
AnsiString  HashFile(const char * sFileName, unsigned long nSkipSize=0,unsigned long nMaxReadSize=0);

private:
int nKeySize;
unsigned   long   int   state[4]; /*   state   (ABCD)   */
unsigned   long   int   count[2]; /*   number   of   bits,   modulo   2^64   (lsb   first)   */
unsigned   char   buffer[64];               /*   input   buffer   */
unsigned   char   PADDING[64]; /*   What?   */

private:
void   MD5Init   ();
void   MD5Transform   (unsigned   long   int   state[4],   unsigned   char   block[64]);
void   MD5_memcpy   (unsigned   char*   output,   unsigned   char*   input,unsigned   int   len);
void   Encode   (unsigned   char   *output,   unsigned   long   int   *input,unsigned   int   len);
void   Decode   (unsigned   long   int   *output,   unsigned   char   *input,   unsigned   int   len);
void   MD5_memset   (unsigned   char*   output,int   value,unsigned   int   len);
};
AnsiString GetMD5( AnsiString FilePath );
//---------------------------------------------------------------------------
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -