diff options
| author | Martin Ridgers <[email protected]> | 2021-12-15 13:43:30 +0100 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-12-16 09:35:51 +0100 |
| commit | e7a7c5b3295e50df0018f3429e2b20729cb08f2f (patch) | |
| tree | 05e627422bd5f22d572ef8b7e9985b7dbd1c646e /zencore/md5.cpp | |
| parent | Deleted unused endian.h include (diff) | |
| download | zen-e7a7c5b3295e50df0018f3429e2b20729cb08f2f.tar.xz zen-e7a7c5b3295e50df0018f3429e2b20729cb08f2f.zip | |
Added MD5 tests
Diffstat (limited to 'zencore/md5.cpp')
| -rw-r--r-- | zencore/md5.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/zencore/md5.cpp b/zencore/md5.cpp index bf11a6b3a..a5a5ea41d 100644 --- a/zencore/md5.cpp +++ b/zencore/md5.cpp @@ -6,6 +6,7 @@ #include <zencore/zencore.h> #include <string.h> +#include <string_view> /* ********************************************************************** @@ -438,6 +439,23 @@ toString(const MD5& value) TEST_CASE("MD5") { + using namespace std::literals; + + auto Input = "jumblesmcgee"sv; + auto Output = "28f2200a59c60b75947099d750c2cc50"sv; + + MD5Stream Stream; + Stream.Append(Input.data(), Input.length()); + MD5 Result = Stream.GetHash(); + + MD5::String_t Buffer; + Result.ToHexString(Buffer); + + CHECK(Output.compare(Buffer)); + + MD5 Reresult = MD5::FromHexString(Buffer); + Reresult.ToHexString(Buffer); + CHECK(Output.compare(Buffer)); } #endif |