PDA

View Full Version : PAWN Hashing Algorithm


ROMDash
07/05/2014, 07:15 PM
Hello everyone!

I'm currently developing the base admin system for use in my future gamemodes, and I'd like to keep it extremely simple, and by simple I don't really want any plugins to be used with it. What I am looking for is a hashing algorithm that is written in pure PAWN so that it doesn't require a plugin, that is secure at the same time. I'm trying to keep everything to one script here to make it as portable as possible.

Thanks in advance!

PS: Apologies if this is the incorrect section, could an admin move the thread to the appropriate section if this is the case.

iZN
07/05/2014, 07:32 PM
You wanted some hashing algorithm which is written in PAWN and also it needs to be secure. It's not possible, they're decryptable easily. I'd use whirlpool plugin instead instead of writing or searching for some ready made hash algorithm. Anyway, I found some udb hash (it's not secure, but if you still wanted to have the hash, you can use this) I still prefer using the whirlpool hash instead of this.


// credits to whoever made this
stock udb_hash(buf[], length = sizeof(buf))
{
new s1 = 1, s2 = 0, n;
for (n = 0; n < length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}

ROMDash
07/05/2014, 07:37 PM
You wanted some hashing algorithm which is written in PAWN and also it needs to be secure. It's not possible, they're decryptable easily. I'd use whirlpool plugin instead instead of writing or searching for some ready made hash algorithm. Anyway, I found some udb hash (it's not secure, but if you still wanted to have the hash, you can use this) I still prefer using the whirlpool hash instead of this.


// credits to whoever made this
stock udb_hash(buf[], length = sizeof(buf))
{
new s1 = 1, s2 = 0, n;
for (n = 0; n < length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}

Ahh okay... Thank you anyway, it's a pity to hear that PAWN isn't cryptographically secure. I might try a PHP script over a HTTPS connection but for now I will use the Whirlpool plugin. There's no way in hell I'd ever use Alder32 (udb_hash) or MD5... ^_^

Djole1337
07/05/2014, 07:54 PM
I might try a PHP script over a HTTPS connection

1) Very slow.

2) Not secure. (even though you're using TLS)

ROMDash
07/05/2014, 08:30 PM
1) Very slow.

2) Not secure. (even though you're using TLS)


I would use local Apache server.
Faster for more hashes, just the response time that would slow it down.
I thought SSL was secure?

Calgon
08/05/2014, 02:11 AM
Why not just use a plugin? I don't understand the problem if you're willing to resort to HTTP(). Also, you can't use https over HTTP().

This plugin has many different methods and should be suitable for you: http://forum.sa-mp.com/showthread.php?t=152682

There is no real disadvantage to using a plugin, apart from operating system compatibility. Simple encryption plugins do not require updating for new versions of SA-MP and should never break in functionality.