2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
5 * Copyright (C) 2013, 2017-2018 Sadie Powell <sadie@witchery.services>
6 * Copyright (C) 2012 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
8 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
9 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
10 * Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
11 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
13 * This file is part of InspIRCd. InspIRCd is free software: you can
14 * redistribute it and/or modify it under the terms of the GNU General Public
15 * License as published by the Free Software Foundation, version 2.
17 * This program is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 /// $CompilerFlags: -Ivendor_directory("sha2")
27 /// $CompilerFlags: require_compiler("GCC") -Wno-long-long
30 # pragma GCC diagnostic push
33 // Fix warnings about the use of `long long` on C++03.
35 # pragma clang diagnostic ignored "-Wc++11-long-long"
36 #elif defined __GNUC__
37 # pragma GCC diagnostic ignored "-Wlong-long"
41 #include "modules/hash.h"
46 # pragma GCC diagnostic pop
49 class HashSHA256 : public HashProvider
52 std::string GenerateRaw(const std::string& data) CXX11_OVERRIDE
54 unsigned char bytes[SHA256_DIGEST_SIZE];
55 sha256((unsigned char*)data.data(), data.length(), bytes);
56 return std::string((char*)bytes, SHA256_DIGEST_SIZE);
59 HashSHA256(Module* parent)
60 : HashProvider(parent, "sha256", 32, 64)
65 class ModuleSHA256 : public Module
69 ModuleSHA256() : sha(this)
73 Version GetVersion() CXX11_OVERRIDE
75 return Version("Implements SHA-256 hashing", VF_VENDOR);
79 MODULE_INIT(ModuleSHA256)