HashLib - Cryptographic hashes in pure Lua

I mean I would of used this if I didn’t have my custom b64 encoding and I currently have no use for hashing though I can see myself using this in other projects!

Thanks ~

1 Like

I actually got it quite a bit faster now.

9 Likes

Thank you so much for your help and contribution!

When I have a chance, I’ll update OP and the module. Done.

You’re a freaking speed demon. Your version of HashLib is scary fast.

2 Likes

This is so cool! Great job, and thank you for posting this! Probably will end up using this down the line.

b64 and hashing are two completely different things… I don’t see what you mean wally

3 Likes

Have to agree with builderboy here, bird boy, Base64 is encoding, something like MD5 is hashing.

2 Likes

I have no idea why you assumed that I said “base64 encoding is hashing”, I know what hashing is…
Also I’m not wally… @NeoInversion

and I currently have no use for hashing

1 Like

Can this module be used to encrypt then decrypt string messages or just hashing?

First post only lists hashing algorithms, not any encryption ones.

It’s HashLib, not EncryptLib.

Cryptographic hashing, by definition, has to be a one way function. No decryption possible. If you could decrypt a hash, then it’s a cracked algorithm and is totally insecure.

2 Likes

Update:

@howmanysmaII went ahead and restructured the module to be easier to read for those of you who are curious, as well as getting it even faster than it already was. She’s truly incredible. Achieving outstanding speed while somehow improving readability is not common.

The latest version is published to the Roblox model.

https://www.roblox.com/library/4544052033/HashLib

5 Likes

Pretty epic module, I’m excited to see what will happen with this however a question have arisen:

  • Would it be reasonable to hash leaderstats (using this module) and send them to an external Database?

Performance wise? Sure.
But why would you be doing that?

I’m interested in knowing why he would as well.

What can be a good use for it?

1 Like

The Game Analytics SDK uses it now, which is a good example of the use of it.

1 Like

Yo, I’m glad you decided to make this because I have a desire to tinker with cryptography! Sent you a friend request on Roblox so I don’t forget to credit you if anything comes of it. Thanks BB and HMS

I don’t think he accepts friend requests from random people. He’s a pretty busy guy. You’d an credit him in the description of your game without friending him.

Thanks for being his spokesman. I was just kidding! How do I decrypt the hash spokesman? I’m hardly random, just keeping the thread alive lol but seriously! How do I reverse the hash back into what it was? People I don’t know are always telling me what to do! shameful.

As stated previously, it is not meant to be decoded.

This is because it is not intended to encrypt/decrypt data for, say, communicating with a remote server but for use to store credentials (such as passwords) instead of the raw string i.e. If you have a password in your game, then instead of doing

local password: string = "password123"

which could potentially be discovered, ruining the point of a password you can do

local password: string = "ef92b778bafe771e89245b89ecbc08a44a4e166c06659911881f383d4473e94f"

and then you can check the password by converting the input using the same hash function, for example:

local hashLib = require(script.HashLib)
local password: string = "ef92b778bafe771e89245b89ecbc08a44a4e166c06659911881f383d4473e94f"
local inputBox: TextBox

inputBox:GetPropertyChangedSignal("Text"):Connect(function()
	local hashedString: string = HashLib.sha256(inputBox.Text) -- Doesn't matter which algorithm, so long as it is the same as the pre-defined variable
	if hashedString == password then
		-- Correct password
	else
		-- Wrong password
	end
end)

Edit: I know this is 3 months after you posted but I only looked at this module now and figured it might still be useful.
Edit2: Came back to change code to Luau style guide format.

2 Likes