diff --git a/Chaos/Hashing/Hash.hpp b/Chaos/Hashing/Hash.hpp new file mode 100644 index 0000000..9038f0e --- /dev/null +++ b/Chaos/Hashing/Hash.hpp @@ -0,0 +1,21 @@ +#ifndef CHAOS_HASHING_HASH_HPP +#define CHAOS_HASHING_HASH_HPP + +#include + +namespace Chaos::Hashing +{ + +template +class Hash +{ +public: + std::string ToHexString() const + { + return static_cast(*this).ToHexString(); + } +}; + +} // namespace Chaos::Hashing + +#endif diff --git a/Chaos/Md4.hpp b/Chaos/Hashing/Md4.hpp similarity index 97% rename from Chaos/Md4.hpp rename to Chaos/Hashing/Md4.hpp index 2c82cf4..e1e34e5 100644 --- a/Chaos/Md4.hpp +++ b/Chaos/Hashing/Md4.hpp @@ -1,11 +1,13 @@ -#ifndef CHAOS_MD4HASHER_HPP -#define CHAOS_MD4HASHER_HPP +#ifndef CHAOS_HASHING_MD4HASHER_HPP +#define CHAOS_HASHING_MD4HASHER_HPP #include #include #include -namespace Chaos::Md4 +#include "Hash.hpp" + +namespace Chaos::Hashing::Md4 { struct Buffer @@ -126,7 +128,7 @@ private: } }; -struct Md4Hash +struct Md4Hash : public Hash { std::string ToHexString() const { diff --git a/Chaos/Md5.hpp b/Chaos/Hashing/Md5.hpp similarity index 98% rename from Chaos/Md5.hpp rename to Chaos/Hashing/Md5.hpp index bac4d19..bc8c83b 100644 --- a/Chaos/Md5.hpp +++ b/Chaos/Hashing/Md5.hpp @@ -1,11 +1,13 @@ -#ifndef CHAOS_MD5HASHER_HPP -#define CHAOS_MD5HASHER_HPP +#ifndef CHAOS_HASHING_MD5HASHER_HPP +#define CHAOS_HASHING_MD5HASHER_HPP #include #include #include -namespace Chaos::Md5 +#include "Hash.hpp" + +namespace Chaos::Hashing::Md5 { struct Buffer @@ -150,7 +152,7 @@ private: } }; -struct Md5Hash +struct Md5Hash : public Hash { std::string ToHexString() const { diff --git a/ChaosTests/Md4HasherTests.cpp b/ChaosTests/Md4HasherTests.cpp index 0595ebd..39526f4 100644 --- a/ChaosTests/Md4HasherTests.cpp +++ b/ChaosTests/Md4HasherTests.cpp @@ -1,8 +1,8 @@ #include -#include "Md4.hpp" +#include "Hashing/Md4.hpp" -using namespace Chaos::Md4; +using namespace Chaos::Hashing::Md4; TEST(Md4Tests, RFCTest) { diff --git a/ChaosTests/Md5HasherTests.cpp b/ChaosTests/Md5HasherTests.cpp index 07e5629..6d267ca 100644 --- a/ChaosTests/Md5HasherTests.cpp +++ b/ChaosTests/Md5HasherTests.cpp @@ -1,8 +1,8 @@ #include -#include "Md5.hpp" +#include "Hashing/Md5.hpp" -using namespace Chaos::Md5; +using namespace Chaos::Hashing::Md5; TEST(Md5Tests, RFCTest) {