note 105703 added to function.crc32

From: Date: Thu, 08 Sep 2011 10:04:25 +0000
Subject: note 105703 added to function.crc32
Groups: php.notes 
Request: Send a blank email to php-notes+get-183027@lists.php.net to get a copy of this message
small sample convert crc32 to character map <?php function khash($data) { static $map="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $hash=crc32($data)+0x100000000; $str = ""; do { $str = $map[31+ ($hash % 31)] . $str; $hash /= 31; } while($hash >= 1); return $str; } $test= array(null,TRUE,FALSE,0,"0",1,"1","2","3","ab","abc","abcd","abcde","abcdefoo"); $out = array(); foreach($test as $s) { $out[]=khash($s).": ". $s; } var_dump($out); /* output: array 0 => string 'zVvOYTv: ' (length=9) 1 => string 'xKDKKL8: 1' (length=10) 2 => string 'zVvOYTv: ' (length=9) 3 => string 'zOKCQxh: 0' (length=10) 4 => string 'zOKCQxh: 0' (length=10) 5 => string 'xKDKKL8: 1' (length=10) 6 => string 'xKDKKL8: 1' (length=10) 7 => string 'AFSzIAO: 2' (length=10) 8 => string 'BXGSvQJ: 3' (length=10) 9 => string 'xZWOQSu: ab' (length=11) 10 => string 'AVAwHOR: abc' (length=12) 11 => string 'zKASNE1: abcd' (length=13) 12 => string 'xLCTOV7: abcde' (length=14) 13 => string 'zQLzKMt: abcdefoo' (length=17) */ ?> ---- Server IP: 203.121.145.121 Probable Submitter: 223.204.25.3 ---- Manual Page -- http://www.php.net/manual/en/function.crc32.php Edit -- https://master.php.net/note/edit/105703 Del: integrated -- https://master.php.net/note/delete/105703/integrated Del: useless -- https://master.php.net/note/delete/105703/useless Del: bad code -- https://master.php.net/note/delete/105703/bad+code Del: spam -- https://master.php.net/note/delete/105703/spam Del: non-english -- https://master.php.net/note/delete/105703/non-english Del: in docs -- https://master.php.net/note/delete/105703/in+docs Del: other reasons-- https://master.php.net/note/delete/105703 Reject -- https://master.php.net/note/reject/105703 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183027) next »