Total Members: 597 [241] Total Tutorials: 284 Newsest User:andrerds Todays Unique Hits: 116
Users Online: 0
7 Guests
Poll
Main Content
Tutorial: Generate a salt By afroxav
Sometimes, there is a need to generate a salt. A salt for any reason at all. Maybe a salt to hash a password, or to generate a key. Well I have a little function/script that can be included in code to generate a salt. The usage is pretty basic: generateSalt($max = 15) where $max is the number of characters to include.
The way that the function works is that it takes a random value between 0 and the number of characters in the list minus one. Since the number is random, it can happen that the same character is included more than once in a salt, which is more random that the php shuffle() function, since each character is independent from the other. This means that the salt could also be longer than the character list.
Difficulty: Easy Views: 137
Rating:
Comments
There are currently no comments for this tutorial.