From 8d2d7e24552a1d086ad24d07a4bcc026331a13c9 Mon Sep 17 00:00:00 2001 From: Layla Manley Date: Sun, 8 Oct 2023 00:43:56 -0400 Subject: [PATCH] iteration --- auth_server.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/auth_server.lua b/auth_server.lua index 229147f..f4539a8 100644 --- a/auth_server.lua +++ b/auth_server.lua @@ -35,12 +35,17 @@ function convert_password(password) return hash(password .. "3m&LmNm7") end --- Does a simple hash of a string +-- Does a complex hash of a string to make it harder to guess function hash(str) local hash = 0 - for i = 1, #str do - hash = hash + string.byte(str, i) + local len = string.len(str) + local byte = 0 + + for i = 1, len do + byte = string.byte(str, i) + hash = bit32.band(hash * 31 + byte, 0xFFFFFFFF) end + return hash end