]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_md5.cpp
Convert the ISO 8859-2 nationalchars files to codepage configs.
[user/henk/code/inspircd.git] / src / modules / m_md5.cpp
index ecf76d07cb8cd7ff06045d8a7e95ee2675fe2d9b..0de69c99a1ca61d1164da86c29736c892cdd3d07 100644 (file)
@@ -1,11 +1,14 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2014 Daniel Vassdal <shutter@canternet.org>
+ *   Copyright (C) 2013, 2015, 2017 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2012 Garrett Holmstrom <gholms@fedoraproject.org>
+ *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2008 Pippijn van Steenhoven <pip88nl@gmail.com>
- *   Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- *   Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -61,23 +64,13 @@ class MD5Provider : public HashProvider
                } while (--words);
        }
 
-       void MD5Init(MD5Context *ctx, unsigned int* ikey = NULL)
+       void MD5Init(MD5Context *ctx)
        {
                /* These are the defaults for md5 */
-               if (!ikey)
-               {
-                       ctx->buf[0] = 0x67452301;
-                       ctx->buf[1] = 0xefcdab89;
-                       ctx->buf[2] = 0x98badcfe;
-                       ctx->buf[3] = 0x10325476;
-               }
-               else
-               {
-                       ctx->buf[0] = ikey[0];
-                       ctx->buf[1] = ikey[1];
-                       ctx->buf[2] = ikey[2];
-                       ctx->buf[3] = ikey[3];
-               }
+               ctx->buf[0] = 0x67452301;
+               ctx->buf[1] = 0xefcdab89;
+               ctx->buf[2] = 0x98badcfe;
+               ctx->buf[3] = 0x10325476;
 
                ctx->bytes[0] = 0;
                ctx->bytes[1] = 0;
@@ -154,7 +147,7 @@ class MD5Provider : public HashProvider
 
        void MD5Transform(word32 buf[4], word32 const in[16])
        {
-               register word32 a, b, c, d;
+               word32 a, b, c, d;
 
                a = buf[0];
                b = buf[1];
@@ -236,37 +229,23 @@ class MD5Provider : public HashProvider
        }
 
 
-       void MyMD5(void *dest, void *orig, int len, unsigned int* ikey)
+       void MyMD5(void *dest, void *orig, int len)
        {
                MD5Context context;
-               MD5Init(&context, ikey);
+               MD5Init(&context);
                MD5Update(&context, (const unsigned char*)orig, len);
                MD5Final((unsigned char*)dest, &context);
        }
 
-
-       void GenHash(const char* src, char* dest, const char* xtab, unsigned int* ikey, size_t srclen)
-       {
-               unsigned char bytes[16];
-
-               MyMD5((char*)bytes, (void*)src, srclen, ikey);
-
-               for (int i = 0; i < 16; i++)
-               {
-                       *dest++ = xtab[bytes[i] / 16];
-                       *dest++ = xtab[bytes[i] % 16];
-               }
-               *dest++ = 0;
-       }
  public:
-       std::string sum(const std::string& data)
+       std::string GenerateRaw(const std::string& data) CXX11_OVERRIDE
        {
                char res[16];
-               MyMD5(res, (void*)data.data(), data.length(), NULL);
+               MyMD5(res, (void*)data.data(), data.length());
                return std::string(res, 16);
        }
 
-       MD5Provider(Module* parent) : HashProvider(parent, "hash/md5", 16, 64) {}
+       MD5Provider(Module* parent) : HashProvider(parent, "md5", 16, 64) {}
 };
 
 class ModuleMD5 : public Module
@@ -279,7 +258,7 @@ class ModuleMD5 : public Module
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Implements MD5 hashing",VF_VENDOR);
+               return Version("Allows other modules to generate MD5 hashes.",VF_VENDOR);
        }
 };