Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- wphashsalted.inc
- "Two easy to use functions that allow you to hash strings as fast as possible."
- Copyright 2013 Giampaolo Falqui
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
- #if !defined WP_Hash
- native WP_Hash(buffer[], len, const str[]);
- #endif
- // stock WhirlpoolHashUnique(string[], salt[], times)
- // string[] - Takes the string you would like to hash.
- // salt[] - Takes a unique salt that will be concatenated with the string and hashed together.
- // times - How many times does the function have to hash the string before returning the value.
- stock WhirlpoolHashUnique(string[], salt[], times)
- {
- new stringTaken[129];
- strcat(stringTaken, string);
- strcat(stringTaken, salt);
- for(new i = 0; i < times; i++)
- WP_Hash(stringTaken, 129, stringTaken);
- return stringTaken;
- }
- // stock WhirlpoolHashRandom(string[], salt[], times)
- // string[] - Takes the string you would like to hash.
- // times - How many times does the function have to hash the string before returning the value.
- // salt[] - Reference string that contains the salt returned by randomString();
- // salt_length - How many characters will contain the salt.
- stock WhirlpoolHashRandom(string[], times, salt[], salt_length)
- {
- new stringTaken[129];
- if(salt_length < 1)
- {
- strcat(stringTaken, "NULL");
- return stringTaken;
- }
- randomString(salt, salt_length);
- strcat(stringTaken, string);
- strcat(stringTaken, salt);
- for(new i = 0; i < times; i++)
- WP_Hash(stringTaken, 129, stringTaken);
- return stringTaken;
- }
- stock randomString(strDest[], strLen = 10)
- {
- while(strLen--)
- strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'A')) : (random(10) + '0');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement