PHP code example of ph-7 / passcode-password-generator

1. Go to this page and download the library: Download ph-7/passcode-password-generator 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/ */

    

ph-7 / passcode-password-generator example snippets


use PH7\Generator\Passcode;

echo Passcode::generate(10); // Generate a 10-length passcode

use PH7\Generator\Passcode;

// By default, it generates a 6 length passcode
echo Passcode::generate();


// You can use the public `Passcode::DEFAULT_LENGTH` const, whcih also gives a 6-length passcode
echo Passcode::generate(Passcode::DEFAULT_LENGTH);

use PH7\Generator\Password;

echo Password::generate(16); // Generate a 16-length password

use PH7\Generator\Password;

// The password won't contain any special characters such as -, _, ~, |, %, ^, !, $, #, @, and ?
echo Password::generate(Password::DEFAULT_LENGTH, false);

use PH7\Generator\Password;

// By default, it generates a 12-length password
echo Password::generate();


// Password::DEFAULT_LENGTH also gives a 12-length password
echo Password::generate(Password::DEFAULT_LENGTH);