Created
June 30, 2016 18:55
-
-
Save diegofelix/49da3c9269de0e2df1b804692214f5ff to your computer and use it in GitHub Desktop.
Keygen.php
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 | |
namespace App\Services; | |
class Keygen { | |
/** | |
* Removed zeroes and o's to avoid missreading | |
* | |
* @var string | |
*/ | |
protected static $hash = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789'; | |
/** | |
* Generate a hash with strings separated by a - | |
* | |
* @param integer $limit | |
* @param integer $chunkSize | |
* @return string | |
*/ | |
public static function make($limit = 11, $chunkSize = 3) | |
{ | |
return substr(chunk_split(str_shuffle(static::$hash), $chunkSize, '-'), 0, $limit); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment