Jump to content

[Util] Lua sha1 function


Kareth

Recommended Posts

Hello everyone, few days ago I was working on a system to communicate a server with a SMF forum, letting players to login using their forum account. SMF engine saves users passwords as a sha1 string, and I started to look for a way of creating a sha1 hash of the password given by players on MTA to compare with the hash on forum database. Since lua does not have such function and MTA provides md5 function only (And there is also a hashing module by mabako if I remember well, but just working for windows), I came out with two possible solutions: using callRemote and making a sha1 hash on a php script was my first option, but I didnt liked the idea of sending the plain text password on a call. So I found over the internet a guy who made a function to generate sha1 hashes in lua. I decided to share it here hoping it will be useful for someone else.

You can find it in the author's web in here: http://regex.info/blog/lua/sha1

I tested it and works absolutely perfect and solved my needs.

Syntax for the function is:

string sha1 (string str) 

An example would be:

outputChatBox (sha1("Password")) 

which would output in chat the next string: 8be3c943b1609fffbfc51aad666d0a04adf83c9d

I just hope this will be useful for someone else as it was for me.

And once again, all credits goes to Jeffrey Friedl ( [email protected] , http://regex.info/blog/ )

Regards

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...