Skip to content

Instantly share code, notes, and snippets.

Created Jun 21, 2011
What would you like to do?
PHP salter
function _salt($string, $len=null)
return (!empty($len)) ?
hash('sha512', str_pad($string, (strlen($string) + $len),
substr(hash('sha512', $string),
round((float)strlen($string)/3, 0,
($len - strlen($string))),
hash('sha512', substr($string,
round((float)strlen($string)/3, 0,

This comment has been minimized.

Copy link
Owner Author

@jas- jas- commented Jun 22, 2011

Uses unique string and length of desired output as arguments.

If string argument is lower then desired output length, the string gets hashed, padded with a divisible return of another hash of the string argument or it will return the hashed portion of the original string argument as a 16 character salt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment