Last active
August 19, 2016 08:34
-
-
Save grimmdev/394e903cf50ba8c65af2 to your computer and use it in GitHub Desktop.
CD Key Generator!
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
// Sean Loper | |
// I use a template so any combination can be used, logically. | |
// Every X is replaced by a random character while 9 is replaced by a random number! | |
function randomKey() | |
{ | |
$template = 'XX99-XX99-99XX-99XX-XXXX-99XX'; | |
$k = strlen($template); | |
$sernum = ''; | |
for ($i=0; $i<$k; $i++) | |
{ | |
switch($template[$i]) | |
{ | |
case 'X': $sernum .= chr(rand(65,90)); break; | |
case '9': $sernum .= rand(0,9); break; | |
case '-': $sernum .= '-'; break; | |
} | |
} | |
return $sernum; // or echo $sernum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment