iteration
This commit is contained in:
@ -25,14 +25,23 @@ function load_data()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function generate_token(user)
|
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
|
data.users[user].token = token
|
||||||
|
|
||||||
return token
|
return token
|
||||||
end
|
end
|
||||||
|
|
||||||
function convert_password(password)
|
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
|
end
|
||||||
|
|
||||||
load_data()
|
load_data()
|
||||||
|
Reference in New Issue
Block a user