From ea5b2af9e85d001d8df668b36d8e0c5be6f5bc9b Mon Sep 17 00:00:00 2001 From: Layla Manley Date: Sun, 8 Oct 2023 00:39:56 -0400 Subject: [PATCH] iteration --- auth_server.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/auth_server.lua b/auth_server.lua index 219a568..229147f 100644 --- a/auth_server.lua +++ b/auth_server.lua @@ -25,14 +25,23 @@ function load_data() end function generate_token(user) - local token = textutils.sha256(user .. os.time() .. math.random()) + local token = hash(user .. os.time() .. math.random()) data.users[user].token = token return token end function convert_password(password) - return textutils.sha256(password .. "3m&LmNm7") + return hash(password .. "3m&LmNm7") +end + +-- Does a simple hash of a string +function hash(str) + local hash = 0 + for i = 1, #str do + hash = hash + string.byte(str, i) + end + return hash end load_data()