PHP code example of jarne / password

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

    

jarne / password example snippets


/**
 * Generate a password
 *
 * @param int $length
 * @param int $lettersChance
 * @param int $numbersChance
 * @param int $specialCharactersChance
 * @return string
 */
public function generate(
    int $length = 8,
    int $lettersChance = 1,
    int $numbersChance = 1,
    int $specialCharactersChance = 1
): string

/**
 * Generate an easy to remember password
 *
 * @param int $length
 * @param int $lettersChance
 * @param int $numbersChance
 * @param int $specialCharactersChance
 * @return string
 */
public function generateEasyToRemember(
    int $length = 8,
    int $lettersChance = 1,
    int $numbersChance = 1,
    int $specialCharactersChance = 1
): string

$password = new Password();

$yourPassword = $password->generate();

echo "Your new password is " . $yourPassword;

$yourPassword = $password->generate(5);

$yourPassword = $password->generate(5, 1, 15, 1);