PHP code example of zhujinkui / hashlib

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

    

zhujinkui / hashlib example snippets


use think\Hashlib;

$hashlib = new Hashlib();

$hashlib->encode(1);

use think\Hashlib;

$hashlib = new Hashlib();

$id = $hashlib->encode(1, 2, 3); // o2fXhV
$numbers = $hashlib->decode($id); // [1, 2, 3]

use think\Hashlib;

$hashlib = new Hashlib();

$hashlib->encode(1, 2, 3); // o2fXhV
$hashlib->encode([1, 2, 3]); // o2fXhV
$hashlib->encode('1', '2', '3'); // o2fXhV
$hashlib->encode(['1', '2', '3']); // o2fXhV

use think\Hashlib;

$hashlib = new Hashlib('My Project');
$hashlib->encode(1, 2, 3); // Z4UrtW

$hashlib = new Hashlib('My Other Project');
$hashlib->encode(1, 2, 3); // gPUasb

use think\Hashlib;

$hashlib = new Hashlib(); // no padding
$hashlib->encode(1); // jR

$hashlib = new Hashlib('', 10); // pad to length 10
$hashlib->encode(1); // VolejRejNm

use think\Hashlib;

$hashlib = new Hashlib('', 0, 'abcdefghijklmnopqrstuvwxyz'); // all lowercase
$hashlib->encode(1, 2, 3); // mdfphx

use think\Hashlib;

$hashlib = new Hashlib();

$id = $hashlib->encodeHex('507f1f77bcf86cd799439011'); // y42LW46J9luq3Xq9XMly
$hex = $hashlib->decodeHex($id); // 507f1f77bcf86cd799439011

	use think\Hashlib;

	$hashlib = new Hashlib();

	$id = $hashlib->encode(1);

	$hashlib->decode($id); // [1]
	

	use think\Hashlib;

	$hashlib = new Hashlib();

	$id = $hashlib->encode('123a');

	$id === ''; // true
	

use think\Hashlib;

$hashlib = new Hashlib();

$hashlib->encode(5, 5, 5); // A6t1tQ

use think\Hashlib;

$hashlib = new Hashlib();

$hashlib->encode(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // wpfLh9iwsqt0uyCEFjHM

$hashlib->encode(1); // jR
$hashlib->encode(2); // k5
$hashlib->encode(3); // l5
$hashlib->encode(4); // mO
$hashlib->encode(5); // nR