PHP code example of carry0987 / sharp
1. Go to this page and download the library: Download carry0987/sharp 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 / sharp example snippets
use carry0987\Sharp\Sharp;
// Initialize the keys and salt. Replace these values with your actual keys and salt.
$signatureKey = 'your_hex_signature_key';
$signatureSalt = 'your_hex_signature_salt';
$sourceKey = 'your_hex_source_key';
// Create a new instance of PHP-Sharp Image Encryptor.
$imageEncryptor = new Sharp($signatureKey, $signatureSalt, $sourceKey);
// The URL of the image you want to encrypt.
$originalImageUrl = 'https://example.com/image.jpg';
try {
// Generate the encrypted and signed URL.
$signedUrl = $imageEncryptor->generateEncryptedUrl($originalImageUrl);
echo 'Encrypted and signed URL: ' . $signedUrl;
} catch (\carry0987\Sharp\Exceptions\SharpException $e) {
// Handle any exceptions during the encryption process.
echo "Error occurred: " . $e->getMessage();
}