Posted By

dygor on 09/04/09


Tagged

hash id crc32


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


convert (nearly) any value into an id-string


 / Published in: PHP
 

convert any value into an id-string

  1. function hash($input)
  2. {
  3. //Create unsigned crc
  4. $input=abs(crc32(serialize($input)));
  5.  
  6. //Build a string representing the crc32
  7. $result="";
  8. while ($input > 0)
  9. {
  10. //Use only a-z
  11. $result.=chr( ($input % 26) + 97);
  12.  
  13. //Decrease value
  14. $input=$input >> 2;
  15. }
  16. //Done
  17. return($result);
  18. }

Report this snippet  

You need to login to post a comment.