PHP code example of teamone / crypt

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

    

teamone / crypt example snippets


use Teamone\Crypt\CryptProvider;

$crypt = CryptProvider::createHash();
// 明文
$data = 'hello Jukit .*?!';
// 密码
$password = '123456';
// 加密
$secure = $crypt->encrypt($data, $password);
// 解密
$verify = $crypt->verify($secure, $secure);

use Teamone\Crypt\CryptProvider;

$crypt = CryptProvider::createPasswordHash();
// 密码
$password = '123456';
// 密码加密
$secure = $crypt->encrypt($password);
// 验证
$verify = $crypt->verify($secure, $password);

use Teamone\Crypt\CryptProvider;

$crypt = CryptProvider::createCryptSimple();
// 明文
$data = 'hello Jukit .*?!';
// 密码
$password = '123456';
// 加密
$secure = $crypt->encrypt($data, $password);
// 解密
$text = $crypt->decrypt($secure, $password);

use Teamone\Crypt\CryptProvider;

$crypt = CryptProvider::createCryptComplex();
// 明文
$data = 'hello Jukit .*?!';
// 密码
$password = '123456';
// 加密
$secure = $crypt->encrypt($data, $password);
// 解密
$text = $crypt->decrypt($secure, $password);

use Teamone\Crypt\CryptProvider;

/** @var RsaAbstract $crypt */
$crypt = CryptProvider::createRsa();
// 明文
$data = 'hello Jukit .*?!';
// 使用私钥加密
$secure = $crypt->encrypt($data, $crypt->getPrivateKey());
// 使用公钥解密
$text = $crypt->decrypt($secure, $crypt->getPublicKey());
`shell
./vendor/bin/phpunit ./test/CryptTest.php --filter testRsa$