PHP code example of inium / php-security-crypto

1. Go to this page and download the library: Download inium/php-security-crypto 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/ */

    

inium / php-security-crypto example snippets



$password = "${YOUR_PASSWORD}";

$bcrypt = new Inium\Security\Crypto\Bcrypt();

$hash = $bcrypt->hash($password);

echo $hash;


$hash = "${PASSWORD_HASH}";     // 암호화된 비밀번호
$password = "${YOUR_PASSWORD}"; // 본래 비밀번호

$bcrypt = new Inium\Security\Crypto\Bcrypt();

$verified = $bcrypt->verify($password, $hash);

if ($verified) {
  echo "Password verification success.";
}
else {
  echo "Password verification fail.";
}


$plainText = "${YOUR_PLAIN_TEXT}";

$key = "${YOUR_AES_KEY}";
$cipherMethod = 'aes-256-cbc';
$useGzCompression = true;

// AES(string $key, string $cipherMethod = 'aes-256-cbc', bool $useGzCompression = false)
$aes = new Inium\Security\Crypto\AES($key, $cipherMethod, $useGzCompression);

$cipherText = $aes->encrypt($plainText);

echo $cipherText;


$cipherText = "${YOUR_CIPHER_TEXT}";

$key = "${YOUR_AES_KEY}";
$cipherMethod = 'aes-256-cbc';
$useGzCompression = true;

$aes = new Inium\Security\Crypto\AES($key, $cipherMethod, $useGzCompression);

$plainText = $aes->decrypt($cipherText);

echo $plainText;
bash
composer