PHP code example of cipher-x / handler

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

    

cipher-x / handler example snippets

bash

// Salt dan IV dihasilkan secara otomatis oleh Handler
$encryptedData = $handler->encrypt($data);
$decryptedData = $handler->decrypt($encryptedData);

echo "Encrypted Data with Salt and IV: " . $encryptedData;
echo "\nDecrypted Data: " . $decryptedData;

bash

 CipherX\Handler;

// Buat kunci enkripsi
$key = 'random-256-bit-long-key-for-security';
$password = "user-password";

// Inisialisasi Handler
$handler = new Handler($key);

// Enkripsi password
$encryptedPassword = $handler->encrypt($password);

// Simpan encryptedPassword ke database (contoh)
echo "Encrypted Password: " . $encryptedPassword;

// Dekripsi password saat login
$decryptedPassword = $handler->decrypt($encryptedPassword);
echo "\nDecrypted Password: " . $decryptedPassword;

bash

 CipherX\Handler;

$key = 'super-secure-file-key-256-bit';
$fileContent = file_get_contents('path/to/your/file.txt');

// Inisialisasi Handler
$handler = new Handler($key);

// Enkripsi file
$encryptedFileContent = $handler->encrypt($fileContent);

// Simpan file terenkripsi
file_put_contents('path/to/your/encrypted-file.txt', $encryptedFileContent);

// Dekripsi file ketika dibutuhkan
$decryptedFileContent = $handler->decrypt($encryptedFileContent);
echo "Decrypted File Content: " . $decryptedFileContent;