aboutsummaryrefslogtreecommitdiff
path: root/src/common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp
index aad420325..69426e2a6 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -353,6 +353,27 @@ gb_global bool global_module_path_set = false;
#include "thread_pool.cpp"
+gb_internal String obfuscate_string(String const &s, char const *prefix) {
+ if (s.len == 0) {
+ return s;
+ }
+ GB_ASSERT(prefix != nullptr);
+ u64 hash = gb_fnv64a(s.text, s.len);
+ gbString res = gb_string_make(permanent_allocator(), prefix);
+ res = gb_string_append_fmt(res, "x%llx", cast(long long unsigned)hash);
+ return make_string_c(res);
+}
+
+gb_internal i32 obfuscate_i32(i32 i) {
+ i32 x = cast(i32)gb_fnv64a(&i, sizeof(i));
+ if (x < 0) {
+ x = 1-x;
+ }
+ return cast(i32)x;
+}
+
+
+
struct StringIntern {
StringIntern *next;
isize len;