Renamed class Hasher to GHash

This commit is contained in:
Leonetienne
2022-05-22 12:55:39 +02:00
parent 4e2f99c28e
commit 734324ec10
3 changed files with 12 additions and 12 deletions

View File

@@ -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<Block> 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) {

View File

@@ -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;
}
}