diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2012-03-19 12:36:11 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2012-03-19 12:36:11 +0000 |
commit | ad5b7acc19290ff91e0f42a0de448a26760fcf99 (patch) | |
tree | 2d1867758835fd0c4e443ff3cc7e5c774af85874 /src/htsmd5.c |
Imported httrack 3.20.2
Diffstat (limited to 'src/htsmd5.c')
-rw-r--r-- | src/htsmd5.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/htsmd5.c b/src/htsmd5.c new file mode 100644 index 0000000..47242d8 --- /dev/null +++ b/src/htsmd5.c @@ -0,0 +1,76 @@ +/* ------------------------------------------------------------ */ +/* +HTTrack Website Copier, Offline Browser for Windows and Unix +Copyright (C) Xavier Roche and other contributors + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +Important notes: + +- We hereby ask people using this source NOT to use it in purpose of grabbing +emails addresses, or collecting any other private information on persons. +This would disgrace our work, and spoil the many hours we spent on it. + + +Please visit our Website: http://www.httrack.com +*/ + + +/* ------------------------------------------------------------ */ +/* File: htsmd5.c subroutines: */ +/* generate a md5 hash */ +/* */ +/* Written March 1993 by Branko Lankester */ +/* Modified June 1993 by Colin Plumb for altered md5.c. */ +/* Modified October 1995 by Erik Troan for RPM */ +/* Modified 2000 by Xavier Roche for domd5mem */ +/* ------------------------------------------------------------ */ + +#include "htsmd5.h" +#include "md5.h" +#include <string.h> +#include <stdio.h> + +int domd5mem(unsigned char * buf, int len, + unsigned char * digest, int asAscii) { + int endian = 1; + unsigned char bindigest[16]; + MD5_CTX ctx; + + MD5Init(&ctx, * ( (char*) &endian)); + MD5Update(&ctx, buf, len); + MD5Final(bindigest, &ctx); + + if (!asAscii) { + memcpy(digest, bindigest, 16); + } else { + sprintf(digest, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" + "%02x%02x%02x%02x%02x", + bindigest[0], bindigest[1], bindigest[2], bindigest[3], + bindigest[4], bindigest[5], bindigest[6], bindigest[7], + bindigest[8], bindigest[9], bindigest[10], bindigest[11], + bindigest[12], bindigest[13], bindigest[14], bindigest[15]); + + } + + return 0; +} + +unsigned long int md5sum32(char* buff) { + char digest[16]; + domd5mem(buff,strlen(buff),digest,0); + return *( (long int*)(char*)digest ); +} |