1. Go to this page and download the library: Download sham3r/cipher-bsk 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/ */
sham3r / cipher-bsk example snippets
ipherBsk\CipherBsk;
$message = "Hajee Mohammad Danesh Science and Technology University";
$key = "Hstu@5200";
$cipherBsk = new CipherBsk();
$encryptedMessage = $cipherBsk->encrypt($message, $key);
echo "Encrypted Message: $encryptedMessage\n";
$decryptedMessage = $cipherBsk->decrypt($encryptedMessage, $key);
echo "Decrypted Message: $decryptedMessage\n";
// Example output:
// Encrypted Message: 7B4D5249784F285E6433232166594C6A5A5A3322532A7C4E4F72697D2B4C52515F7400753644674061576C254E47724635612920714C6A21
// Decrypted Message: Hajee Mohammad Danesh Science and Technology University
// Inject via service container
class UserController extends Controller
{
public function hashPassword(Request $request, CipherBsk $cipher)
{
$password = $request->input('password');
$hash = $cipher->secureHash($password);
// Store $hash in database
User::create(['password' => $hash]);
return response()->json(['success' => true]);
}
public function verifyPassword(Request $request, CipherBsk $cipher)
{
$user = User::find($request->user_id);
$inputPassword = $request->input('password');
$isValid = $cipher->verifyHash($inputPassword, $user->password);
return response()->json(['valid' => $isValid]);
}
}
// This still works exactly the same
$cipher = new CipherBsk();
$encrypted = $cipher->encrypt($message, $key);
$decrypted = $cipher->decrypt($encrypted, $key);
// Original features
$cipher = new CipherBsk();
$encrypted = $cipher->encrypt($message, $key);
// New secure hashing (hash);
bash
php artisan vendor:publish --tag=config
bash
# Test basic encryption/decryption
vendor/bin/phpunit tests/CipherBskTest.php --testdox
# Test secure hashing features
vendor/bin/phpunit tests/SecureHashTest.php --testdox
# Test key generation
vendor/bin/phpunit tests/KeyGeneratorTest.php --testdox
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.