Skip to content

Instantly share code, notes, and snippets.

@omarbadran
Created March 22, 2020 07:49
Show Gist options
  • Save omarbadran/5decaa05e3743cb3e24d01b4d7b844b0 to your computer and use it in GitHub Desktop.
Save omarbadran/5decaa05e3743cb3e24d01b4d7b844b0 to your computer and use it in GitHub Desktop.
<?php
$tokens = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$segment_chars = 5;
$num_segments = 4;
$key_string = '';
for ($i = 0; $i < $num_segments; $i++) {
$segment = '';
for ($j = 0; $j < $segment_chars; $j++) {
$segment .= $tokens[rand(0, 35)];
}
$key_string .= $segment;
if ($i < ($num_segments - 1)) {
$key_string .= '-';
}
}
echo $key_string;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment