PHP code example of ucscode / keygenerator

1. Go to this page and download the library: Download ucscode/keygenerator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ucscode / keygenerator example snippets




use Ucscode\KeyGenerator\KeyGenerator;

// Create a new instance of the key generator
$keyGenerator = new KeyGenerator();

// Generate a random key of length 10
$key = $keyGenerator->generateKey(10);

// Generate a random key with prefix and suffix
$key = $keyGenerator->generateKey(5, 'app-', '-volvo');

echo $key; // app-SNb9P-volvo

/**
 * Generate random keys between 'A' and 'Z'
 * 
 * @param string|array
 */
$keyGenerator->setCharacters(range('A', 'Z'));

/** 
 * This will also generate random keys between 'A' and 'Z' 
 * 
 * @param string|array
 */
$keyGenerator->setCharacters('ABCDEFGHIJKLMNOPQRSTUVWXYZ');

/**
 * Add more possible characters to the list of generated keys
 * 
 * @param string|array
 */
$keyGenerator->addCharacters(['#', '@', '%']);

/**
 * Remove one or more character from the list
 * 
 * The "@" symbol will not be part of possible value from the characters
 * 
 * @param string|array
 */
$keyGenerator->removeCharacters('@');

/**
 * Apply usage of the system default special characters
 * 
 * By default, if no configuration is made, the key generator will only contain alpha numeric outputs
 * 
 * @param bool
 */
$keyGenerator->applySpecialCharacters(true);