Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Last active April 18, 2018 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gladchinda/65302b32cbce19983f9ee03ed548d515 to your computer and use it in GitHub Desktop.
Save gladchinda/65302b32cbce19983f9ee03ed548d515 to your computer and use it in GitHub Desktop.
Code to test how to use Keygen transformations.
<?php
require __DIR__ . '/vendor/autoload.php';
use Keygen\Keygen;
$splitString = function($key) {
return join('-', str_split($key, 4));
};
$shortHash20 = function($key) {
return substr(md5($key), mt_rand(0,8), 20);
};
$reference = Keygen::numeric(20)->generate($splitString);
$filename = Keygen::bytes()->suffix('.png')->generate(true, ['strrev', $shortHash20], 'strtoupper');
echo $reference; // 2129-1489-0676-5152-9337
echo $filename; // 159D702E346F74E3F0B6.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment