[Include] wphashsalted.inc | Easy to Use Hashing Functions | Salts Included
#5

Код:
#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;
}
Test:

Quote:

WhirlpoolHashUnique("Hello world", 4, "Hello");
WhirlpoolHashUnique("Hello world", 4);

What about a single function?

I used MAX_SALT_LENGTH to avoid error for

"
realsalt = salt;
"

ofc, you can use ofc a different way.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)