PHP code example of xavierfaucon / bravoids

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

    

xavierfaucon / bravoids example snippets



/**
 *
 * @param int $number The ID you want to convert into a hash
 * @param string $passPhrase  A passphrase that you must provide
 * @param int $minHashLength Specify the minimum length for the output.
 * @param bool $safeCharacters Remove all the vowels to generate the output to avoid curse words
 *
 * @return string The hash of a converted ID.
 */
BravoIDs::encrypt($number, $passPhrase, $minHashLength = 0, $safeCharacters = true);



 BravoIDs::decrypt(string $hash, string $passPhrase, int $minHashLength = 0, bool $safeCharacters = true);
 



echo BravoIDs::encrypt (123, 'myPassPhrase');
// "tr"

echo BravoIDs::decrypt ('tr', 'myPassPhrase');
// "123"




echo BravoIDs::encrypt (123, 'myPassPhrase', 4);
// "kNtr"

echo BravoIDs::decrypt ('kNtr', 'myPassPhrase', 4);
// "123"




echo BravoIDs::encrypt (123, 'myPassPhrase', 4, false);
// "5u59"

echo BravoIDs::decrypt ('5u59', 'myPassPhrase', 4, false);
// "123"