Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

This hashing algorithm is it secure enough?

So, i have been working on a hashing algorithm (just for fun, might serve a purpose later on) that is ideally not easily reversible. Would this kind of algorithm be considered secure?:

conv = 'string here'

local clist = {}
local final = ''
for i in string.gmatch(conv,".") do
	clist[#clist+1] = i
end
for i = 1,#clist do
	final = final..string.byte(clist[i])
end
final = final*#tostring(final)

ab = tonumber(final)

output = ab*math.random(1,127476348)/math.random(1,999)*ab-math.random(31262,13648567259)+math.random(17,146)/ab

output = tostring(output):sub(3,14)

print(output)

-- This returns: 688772902233

Here are some others i tried, to make sure a different result was given every time:

309598494271 'hello boiz' 831025705350 'hello boiiz' 405479412471 'hello booiiz'

Sorry if this is a silly question, i am new to Roblox development & lua.

4 comments

0

Does hashing the same string return the same output every time?

0

The point of it is that you hash a password when its created, then when the password is asked for, the attempt is hashed to see if it matches.

0

Yeah it always produces the same answer on the same input.

0

This is not a hashing algorithm, it is a psudorandom number generator (which is likely less secure than the normal math:random()).

1 answer

  1. This is not a hashing algorithm, it is a psudorandom number generator that is biasable from an input. This is because a hash function maps an input to one and only one output.
  2. It is more than likely less secure than math.random().
  3. If you want a hashing algorithm use proven cryptographically secure hashes. There is a reason why people made them, tested them, scrutinized them, analyzed them. SHA256 and PBKDF2 (a key derivation function for passwords) are two acceptable cryptographically secure hash functions.

2 comments

0

Is there a Roblox version of PBKDF2? U

0

There are Lua implementations of PBKDF2 that are open source. Roblox does not have a PBKDF2 implementation natively.

This discussion is preserved as it was. New answers, comments, and votes are closed.