有的时候需要用HASH来对数据标注,PHP下无疑就是Md5了,不过呢如果这个哈希是给用户看的呢?总之试图实现4chan的tripcode(绊码)功能时候发现:
/********* * CHash provides users with a fairly strong but short hash for identification * Based on MD5 **********/ class stdHash{ var $hashIn = ''; function __construct($hashIn=''){ $this->hashIn = $hashIn; } function hash($string){ $cherryTable = Array('0'=>0,'1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7,'8'=>8,'9'=>9,'A'=>10,'B'=>11,'C'=>12,'D'=>13,'E'=>14,'F'=>15); $md = md5($string.$this->hashIn);$m=""; for($i=0;$i