Created
July 17, 2014 21:07
-
-
Save nfreader/d378ba5a35d31d038869 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* hexPrint | |
* | |
* Mutilates a given string into a unique, Cool Looking(tm) hex string | |
* | |
* @string (string) The string we're abusing | |
* @prefix (string) A few characters we can use to denote a hex string. Default | |
* is '0x' | |
* | |
* @return (string) A Cool Looking(tm) hex string | |
* | |
*/ | |
function hexPrint($string,$prefix="0x") { | |
$string = str_split(bin2hex(substr(sha1($string),32))); | |
$output = $prefix; | |
$i = 1; | |
foreach($string as $char) { | |
$output.= $char; | |
if ($i==2) { | |
$output.=':'; | |
$i = 0; | |
} | |
$i++; | |
} | |
return substr($output,0,-1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment