The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

m_hash.h

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #ifndef __HASH_H__
00015 #define __HASH_H__
00016 
00017 #include "modules.h"
00018 
00019 #define SHA256_DIGEST_SIZE (256 / 8)
00020 #define SHA256_BLOCK_SIZE  (512 / 8)
00021 
00027 class HashRequest : public Request
00028 {
00030         unsigned int* keys;
00032         const char* outputs;
00034         std::string tohash;
00035  public:
00037         HashRequest(const char* req, Module* Me, Module* Target) : Request(Me, Target, req)
00038         {
00039         }
00040 
00042         HashRequest(Module* Me, Module* Target, const std::string &hashable) : Request(Me, Target, "SUM"), keys(NULL), outputs(NULL), tohash(hashable)
00043         {
00044         }
00045 
00047         HashRequest(Module* Me, Module* Target, unsigned int* k) : Request(Me, Target, "KEY"), keys(k), outputs(NULL), tohash("")
00048         {
00049         }
00050 
00052         HashRequest(Module* Me, Module* Target, const char* out) : Request(Me, Target, "HEX"), keys(NULL), outputs(out), tohash("")
00053         {
00054         }
00055 
00057         std::string& GetHashData()
00058         {
00059                 return tohash;
00060         }
00061 
00063         unsigned int* GetKeyData()
00064         {
00065                 return keys;
00066         }
00067 
00069         const char* GetOutputs()
00070         {
00071                 return outputs;
00072         }
00073 };
00074 
00082 class HashNameRequest : public HashRequest
00083 {
00084  public:
00089         HashNameRequest(Module* Me, Module* Target) : HashRequest("NAME", Me, Target)
00090         {
00091         }
00092 };
00093 
00105 class HashResetRequest : public HashRequest
00106 {
00107  public:
00112         HashResetRequest(Module* Me, Module* Target) : HashRequest("RESET", Me, Target)
00113         {
00114         }
00115 };
00116 
00130 class HashSumRequest : public HashRequest
00131 {
00132  public:
00138         HashSumRequest(Module* Me, Module* Target, const std::string &sdata) : HashRequest(Me, Target, sdata)
00139         {
00140         }
00141 };
00142 
00155 class HashKeyRequest : public HashRequest
00156 {
00157  public:
00164         HashKeyRequest(Module* Me, Module* Target, unsigned int* sdata) : HashRequest(Me, Target, sdata)
00165         {
00166         }
00167 };
00168 
00181 class HashHexRequest : public HashRequest
00182 {
00183  public:
00190         HashHexRequest(Module* Me, Module* Target, const char* sdata) : HashRequest(Me, Target, sdata)
00191         {
00192         }
00193 };
00194 
00195 #endif
00196