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 # pragma GCC diagnostic push
29 // Fix warnings about the use of `long long` on C++03.
31 # pragma clang diagnostic ignored "-Wc++11-long-long"
32 #elif defined __GNUC__
33 # pragma GCC diagnostic ignored "-Wlong-long"
37 #include "modules/hash.h"
42 # pragma GCC diagnostic pop
45 class HashSHA256 : public HashProvider
48 std::string GenerateRaw(const std::string& data) CXX11_OVERRIDE
50 unsigned char bytes[SHA256_DIGEST_SIZE];
51 sha256((unsigned char*)data.data(), data.length(), bytes);
52 return std::string((char*)bytes, SHA256_DIGEST_SIZE);
55 HashSHA256(Module* parent)
56 : HashProvider(parent, "sha256", 32, 64)
61 class ModuleSHA256 : public Module
65 ModuleSHA256() : sha(this)
69 Version GetVersion() CXX11_OVERRIDE
71 return Version("Implements SHA-256 hashing", VF_VENDOR);
75 MODULE_INIT(ModuleSHA256)