WhirlpoolHashUnique("TestingString", "RandomStringAsSalt", 500, true);
// Make sure the local variable length is big enough as you've entered in the hashing function.
new saltUsed[50];
WhirlpoolHashRandom("TestingPassword", saltUsed, 250, 45, true);
new saltUsed[50], hashedPassword1[129], hashedPassword2[129];
strcat(hashedPassword1, WhirlpoolHashRandom("password", 500, saltUsed, 24), 129);
printf("hashedPassword1 = %s", hashedPassword1);
strcat(hashedPassword2, WhirlpoolHashUnique("password", saltUsed, 500), 129);
printf("hashedPassword2 = %s", hashedPassword2);
if(!strcmp(hashedPassword1, hashedPassword2, false))
print("The password is correct.");
else
print("The password is not correct.");
Testing Code:
pawn Код:new timer = GetTickCount();
print("The entire process just started.");
new saltUsed[50], hashedPassword1[129], hashedPassword2[129];
print("WhirlpoolHashRandom started executing.");
strcat(hashedPassword1, WhirlpoolHashRandom("password", 5000, saltUsed, 24, false), 129);
printf("WhirlpoolHashRandom stopped executing, hash is %s.", hashedPassword1);
print("WhirlpoolHashUnique started executing.");
strcat(hashedPassword2, WhirlpoolHashUnique("password", 5000, saltUsed, false), 129);
printf("WhirlpoolHashUnique stopped executing, hash is %s.", hashedPassword2);
printf("The entire process took %d milliseconds.", GetTickCount() - timer);
Tests done with an Intel Core i7 920 @ 2,67 Ghz - 4 cores, 8 threads
[00:13:39] The entire process just started. [00:13:39] WhirlpoolHashRandom started executing. [00:13:39] WhirlpoolHashRandom stopped executing, hash is 48AD51DE0CFE8A30E92ED27040855770FEA716411153A50D47 A61B31704E21DEC9908D28E4C9F681FBA45E4949A4CCB50E42 71803ED47B30ADCF75E22B720C38. [00:13:39] WhirlpoolHashUnique started executing. [00:13:39] WhirlpoolHashUnique stopped executing, hash is 48AD51DE0CFE8A30E92ED27040855770FEA716411153A50D47 A61B31704E21DEC9908D28E4C9F681FBA45E4949A4CCB50E42 71803ED47B30ADCF75E22B720C38. [00:13:39] The entire process took 5 milliseconds. |
[00:14:20] The entire process just started. [00:14:20] WhirlpoolHashRandom started executing. [00:14:20] WhirlpoolHashRandom stopped executing, hash is 8DBC216179F6AAB3E52FA4D73760D517FA283FF124559EF4EA E099D6AA009D43AA162EABE70EA179FEA0B608F73861BF1771 71F065B7ECBC52741AC8EE3A93B4. [00:14:20] WhirlpoolHashUnique started executing. [00:14:20] WhirlpoolHashUnique stopped executing, hash is 8DBC216179F6AAB3E52FA4D73760D517FA283FF124559EF4EA E099D6AA009D43AA162EABE70EA179FEA0B608F73861BF1771 71F065B7ECBC52741AC8EE3A93B4. [00:14:20] The entire process took 20 milliseconds. |
[00:14:52] The entire process just started. [00:14:52] WhirlpoolHashRandom started executing. [00:14:52] WhirlpoolHashRandom stopped executing, hash is B3D09A9BD8709E5584DDFC5D3CFC70ED9195FE4194F2202200 DAFE1FDCF222DDD28AA795932EB54A607B208187B1FDC5D4E8 78F619899D542EBFFD6A85A00FE6. [00:14:52] WhirlpoolHashUnique started executing. [00:14:52] WhirlpoolHashUnique stopped executing, hash is B3D09A9BD8709E5584DDFC5D3CFC70ED9195FE4194F2202200 DAFE1FDCF222DDD28AA795932EB54A607B208187B1FDC5D4E8 78F619899D542EBFFD6A85A00FE6. [00:14:52] The entire process took 181 milliseconds. |
[00:15:36] The entire process just started. [00:15:36] WhirlpoolHashRandom started executing. [00:15:37] WhirlpoolHashRandom stopped executing, hash is 018A7176EEA2869223AAEAC7A458461DB3473B7CFEF5EC5945 D9B2CFA71EDDB326947274EFAEF26127D767FA4765FA51B788 4FF7DAEF571EC7035CB03ABA3139. [00:15:37] WhirlpoolHashUnique started executing. [00:15:37] WhirlpoolHashUnique stopped executing, hash is 018A7176EEA2869223AAEAC7A458461DB3473B7CFEF5EC5945 D9B2CFA71EDDB326947274EFAEF26127D767FA4765FA51B788 4FF7DAEF571EC7035CB03ABA3139. [00:15:37] The entire process took 443 milliseconds. |
[00:17:02] The entire process just started. [00:17:02] WhirlpoolHashRandom started executing. [00:17:02] WhirlpoolHashRandom stopped executing, hash is FA43E2B1B572D4CEB5B18FEA98535FD8992D05513F0304053A 92637059ED033FB3E5EC4A2986F2429984324B59FBB3BCB62D F5AB5420B5B330D4A19CA7F25ECC. [00:17:02] WhirlpoolHashUnique started executing. [00:17:03] WhirlpoolHashUnique stopped executing, hash is FA43E2B1B572D4CEB5B18FEA98535FD8992D05513F0304053A 92637059ED033FB3E5EC4A2986F2429984324B59FBB3BCB62D F5AB5420B5B330D4A19CA7F25ECC. [00:17:03] The entire process took 889 milliseconds. |
[00:17:48] The entire process just started. [00:17:48] WhirlpoolHashRandom started executing. [00:17:49] WhirlpoolHashRandom stopped executing, hash is CE415C9F912581121E3139CF645F3427057523703CB9F21DC8 5F13088F43ABE3BEE2CF42E5B0864A8F25514959F3FDDD3CCA 5AEF229FFF1E74886128A31134CD. [00:17:49] WhirlpoolHashUnique started executing. [00:17:49] WhirlpoolHashUnique stopped executing, hash is CE415C9F912581121E3139CF645F3427057523703CB9F21DC8 5F13088F43ABE3BEE2CF42E5B0864A8F25514959F3FDDD3CCA 5AEF229FFF1E74886128A31134CD. [00:17:49] The entire process took 1771 milliseconds. |
R2 - Modified parameters order of WhirlpoolHashRandom. - Added the paramater iter_append to choose if appending the salt for every iteration. It slightly slows down the process but it increases the security. - Fixed minor internal documentation mistakes. R1 - Initial release. |
It is useless to hash a password more than once. You already have support for a salt which is plenty secure.
|
- Modified parameters order of WhirlpoolHashRandom. - Added the paramater iter_append to choose if appending the salt for every iteration. It slightly slows down the process but it increases the security. - Fixed minor internal documentation mistakes. |
#define MAX_SALT_LENGTH 128 stock WhirlpoolHashUnique(string[], times, salt[MAX_SALT_LENGTH] = "", bool: iter_append = false, salt_length = 10) { new stringTaken[258]; new realsalt [MAX_SALT_LENGTH]; //here i miss c++ if (salt[0] == '\0') { randomString(realsalt, salt_length); } else realsalt = salt; if(!iter_append) { strcat(stringTaken, string, 258); strcat(stringTaken, realsalt, 258); for(new i = 0; i < times; i++) WP_Hash(stringTaken, 258, stringTaken); } else { strcat(stringTaken, string); for(new i = 0; i < times; i++) { strcat(stringTaken, realsalt); WP_Hash(stringTaken, 258, stringTaken); } } return stringTaken; }
WhirlpoolHashUnique("Hello world", 4, "Hello"); WhirlpoolHashUnique("Hello world", 4); |