2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
6 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
7 * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
9 * This file is part of InspIRCd. InspIRCd is free software: you can
10 * redistribute it and/or modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation, version 2.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 /// $CompilerFlags: -Ivendor_directory("sha2")
23 /// $CompilerFlags: require_compiler("GCC") -Wno-long-long
26 // Fix warnings about the use of `long long` on C++03.
28 # pragma clang diagnostic ignored "-Wc++11-long-long"
29 #elif defined __GNUC__
30 # pragma GCC diagnostic ignored "-Wlong-long"
34 #include "modules/hash.h"
38 class HashSHA256 : public HashProvider
41 std::string GenerateRaw(const std::string& data) CXX11_OVERRIDE
43 unsigned char bytes[SHA256_DIGEST_SIZE];
44 sha256((unsigned char*)data.data(), data.length(), bytes);
45 return std::string((char*)bytes, SHA256_DIGEST_SIZE);
48 HashSHA256(Module* parent)
49 : HashProvider(parent, "sha256", 32, 64)
54 class ModuleSHA256 : public Module
58 ModuleSHA256() : sha(this)
62 Version GetVersion() CXX11_OVERRIDE
64 return Version("Implements SHA-256 hashing", VF_VENDOR);
68 MODULE_INIT(ModuleSHA256)