Guest User

Untitled

a guest
Jul 17th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <?php
  2. // SALT FUNCTION
  3. // returns a salted and sha1ed string
  4.  
  5. function salt( $string, $salt="lsaklALKJD29+3139+=?=)!?#=)?=!)(_xXx!£¤&/{]s()}=?+\^~*aslskdaXDAO=)" )
  6. {
  7.  
  8. $chars = "abcdefghijklmnopqrstvwxyzABCDEFGHIJKLMNOPQRSTVWXYZ";
  9.  
  10. $string .= substr($chars,0,10-strlen($string)); // Adds characters to string to make sure it's not empty
  11. $salt .= substr($chars,0,10-strlen($salt)); // Same for the salt
  12.  
  13. $strlen = strlen($string); // Get string length
  14. $half = ceil( $strlen / 2 ); // Get half string int
  15. $smallint = ceil( strlen($salt) % 10 + 1); // Get a small int :)
  16.  
  17. // Add some salt for extra taste
  18. $salted = substr($salt,0,$smallint) . substr($string,0,$half) . substr($salt,$smallint) . substr($string, $half) . substr($salt,-$smallint);
  19.  
  20. // Smoke hash
  21. return sha1($salted);
  22.  
  23. }
Add Comment
Please, Sign In to add comment