1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
19 #define SHA256_DIGEST_SIZE (256 / 8)
20 #define SHA256_BLOCK_SIZE (512 / 8)
22 class HashProvider : public DataProvider
25 HashProvider(Module* mod, const std::string& Name) : DataProvider(mod, Name) {}
26 virtual std::string sum(const std::string& data) = 0;
27 inline std::string hexsum(const std::string& data)
29 return BinToHex(sum(data));
32 inline std::string b64sum(const std::string& data)
34 return BinToBase64(sum(data), NULL, 0);
37 /** Allows the IVs for the hash to be specified. As the choice of initial IV is
38 * important for the security of a hash, this should not be used except to
39 * maintain backwards compatability. This also allows you to change the hex
40 * sequence from its default of "0123456789abcdef", which does not improve the
41 * strength of the output, but helps confuse those attempting to implement it.
45 * unsigned int iv[] = { 0xFFFFFFFF, 0x00000000, 0xAAAAAAAA, 0xCCCCCCCC };
46 * std::string result = Hash.sumIV(iv, "fedcba9876543210", "data");
49 virtual std::string sumIV(unsigned int* IV, const char* HexMap, const std::string &sdata) = 0;