PHP code example of carry0987 / hash

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

    

carry0987 / hash example snippets


use carry0987\Hash\Hash;

// Initialize with your signature key and signature salt
$hash = new Hash('your_hex_signature_key', 'your_hex_signature_salt');

// Set a custom encryption cipher
$hash->setCipher('aes-256-gcm');

// Set a custom encryption algorithm for generating binary signatures
$hash->setEncryptAlgorithm('sha256');

// Optionally, set a custom Additional Authenticated Data (AAD) for AEAD ciphers
$hash->setAAD('your_custom_aad');

// Customize the encrypted path's prefix and suffix
$hash->setPrefix('/custom-prefix');
$hash->setSuffix('/custom-suffix');

$originalUrl = 'https://yourdomain.com/original/path';
$encryptedUrl = $hash->generateEncryptedUrl($originalUrl);
echo $encryptedUrl;

$hash->setPathFormatter(function ($encryptedUrl, $options) {
    // Your custom logic here
    return "/custom/format/$encryptedUrl";
});