From 4705e3fa53ef9ed18d1469f9116708d25fb7e230 Mon Sep 17 00:00:00 2001 From: vxunderground <57078196+vxunderground@users.noreply.github.com> Date: Thu, 14 Jul 2022 22:31:42 -0500 Subject: [PATCH] Create HashStringUnknownGenericHash1.cpp --- .../HashStringUnknownGenericHash1.cpp | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Cryptography Related/String Hashing/HashStringUnknownGenericHash1.cpp diff --git a/Cryptography Related/String Hashing/HashStringUnknownGenericHash1.cpp b/Cryptography Related/String Hashing/HashStringUnknownGenericHash1.cpp new file mode 100644 index 0000000..eb285fc --- /dev/null +++ b/Cryptography Related/String Hashing/HashStringUnknownGenericHash1.cpp @@ -0,0 +1,39 @@ +INT HashStringUnknownGenericHash1A(PCHAR String) +{ + PCHAR Pointer; + INT Generic; + INT Hash = 0; + + for (Pointer = String; *Pointer != '\0'; Pointer++) + { + Hash = (Hash << 4) + (INT)(*Pointer); + Generic = Hash & 0xF0000000L; + + if (Generic != 0) + Hash = Hash ^ (Generic >> 24); + + Hash = Hash & ~Generic; + } + + return Hash; +} + +INT HashStringUnknownGenericHash1W(PWCHAR String) +{ + PWCHAR Pointer; + INT Generic; + INT Hash = 0; + + for (Pointer = String; *Pointer != '\0'; Pointer++) + { + Hash = (Hash << 4) + (INT)(*Pointer); + Generic = Hash & 0xF0000000L; + + if (Generic != 0) + Hash = Hash ^ (Generic >> 24); + + Hash = Hash & ~Generic; + } + + return Hash; +}