Skip to content

Instantly share code, notes, and snippets.

@nfreader
Created July 17, 2014 21:07
Show Gist options
  • Save nfreader/d378ba5a35d31d038869 to your computer and use it in GitHub Desktop.
Save nfreader/d378ba5a35d31d038869 to your computer and use it in GitHub Desktop.
<?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