From dd22e1ab7ab7b5bac841dae2b62bfa200b36c4d8 Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Wed, 12 Feb 2025 23:57:32 +0100 Subject: add encryption/decryption --- lib/nes/app/crypto/sha256.hh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/nes/app/crypto/sha256.hh (limited to 'lib/nes/app/crypto/sha256.hh') diff --git a/lib/nes/app/crypto/sha256.hh b/lib/nes/app/crypto/sha256.hh new file mode 100644 index 0000000..55ba202 --- /dev/null +++ b/lib/nes/app/crypto/sha256.hh @@ -0,0 +1,28 @@ +#pragma once + +#include "nes/common/containers/span.hh" +#include "nes/common/types.hh" + +namespace nes::app +{ + class sha256 + { + static constexpr auto length = u32{ 256 / 8 }; + static constexpr auto block_size = u32{ 512 / 8 }; + + u8 data_[length]{}; + + public: + static auto hash(span) -> sha256; + + auto get_data() const -> span { return data_; } + + private: + explicit sha256(); + + auto combine(span) -> void; + + auto get(u32 index) -> u32; + auto set(u32 index, u32 value) -> void; + }; +} // namespace nes::app \ No newline at end of file -- cgit v1.3.1