diff --git a/GCryptLib/include/GCrypt/Hasher.h b/GCryptLib/include/GCrypt/GHash.h similarity index 91% rename from GCryptLib/include/GCrypt/Hasher.h rename to GCryptLib/include/GCrypt/GHash.h index a576137..bf5301f 100644 --- a/GCryptLib/include/GCrypt/Hasher.h +++ b/GCryptLib/include/GCrypt/GHash.h @@ -1,5 +1,5 @@ -#ifndef GCRYPT_HASHER_H -#define GCRYPT_HASHER_H +#ifndef GCRYPT_GHASH_H +#define GCRYPT_GHASH_H #include "GCrypt/Flexblock.h" #include "GCrypt/Block.h" @@ -8,9 +8,9 @@ namespace Leonetienne::GCrypt { /** This class implements a hash function, based on the GCrypt cipher */ - class Hasher { + class GHash { public: - Hasher(); + GHash(); //! Will add the hash value of the block `data` to the hashsum. //! WARNING: If you compute hashes using this digestive method, diff --git a/GCryptLib/src/Hasher.cpp b/GCryptLib/src/GHash.cpp similarity index 84% rename from GCryptLib/src/Hasher.cpp rename to GCryptLib/src/GHash.cpp index 9e117ea..34864b1 100644 --- a/GCryptLib/src/Hasher.cpp +++ b/GCryptLib/src/GHash.cpp @@ -1,10 +1,10 @@ -#include "GCrypt/Hasher.h" +#include "GCrypt/GHash.h" #include "GCrypt/Util.h" #include "GCrypt/InitializationVector.h" namespace Leonetienne::GCrypt { - Hasher::Hasher() : + GHash::GHash() : // Initialize our cipher with a static, but randomly distributed key. cipher( StringToBitblock("CfRtNdMTP4Y5CWRd"), @@ -15,17 +15,17 @@ namespace Leonetienne::GCrypt { return; } - void Hasher::DigestBlock(const Block& data) { + void GHash::DigestBlock(const Block& data) { // Encipher the current block, and xor it on the current hashsum block ^= cipher.Digest(data); return; } - const Block& Hasher::GetHashsum() const { + const Block& GHash::GetHashsum() const { return block; } - Block Hasher::CalculateHashsum(const Flexblock& data) { + Block GHash::CalculateHashsum(const Flexblock& data) { // Split input into blocks std::vector blocks; @@ -42,7 +42,7 @@ namespace Leonetienne::GCrypt { blocks.push_back(lengthBlock); // Create hasher instance - Hasher hasher; + GHash hasher; // Digest all blocks for (Block& block : blocks) { diff --git a/GCryptLib/src/Util.cpp b/GCryptLib/src/Util.cpp index 11f2179..f514451 100644 --- a/GCryptLib/src/Util.cpp +++ b/GCryptLib/src/Util.cpp @@ -1,12 +1,12 @@ #include "GCrypt/Util.h" -#include "GCrypt/Hasher.h" +#include "GCrypt/GHash.h" namespace Leonetienne::GCrypt { Block PasswordToKey(const std::string& in) { // We already have a hashing algorithm, so why not use it // Yeah, this won't work, because it would create an include loop. This method needs to be outsourced to a cpp file.. - const Block hashedPassword = Hasher::CalculateHashsum(StringToBits(in)); + const Block hashedPassword = GHash::CalculateHashsum(StringToBits(in)); return hashedPassword; } }