1. Go to this page and download the library: Download jedisct1/ipcrypt 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/ */
jedisct1 / ipcrypt example snippets
use Ipcrypt\IpcryptDeterministic;
// Generate a random 16-byte key
$key = IpcryptDeterministic::generateKey();
// Example with IPv4
$ipv4 = '192.0.2.1';
$encrypted = IpcryptDeterministic::encrypt($ipv4, $key);
$decrypted = IpcryptDeterministic::decrypt($encrypted, $key);
// Example with IPv6
$ipv6 = '2001:db8::1';
$encrypted = IpcryptDeterministic::encrypt($ipv6, $key);
$decrypted = IpcryptDeterministic::decrypt($encrypted, $key);
use Ipcrypt\IpcryptNd;
// Generate a random 16-byte key
$key = IpcryptNd::generateKey();
$ip = '192.0.2.1';
// Each encryption produces a different result
$encrypted1 = IpcryptNd::encrypt($ip, $key); // Uses random 8-byte tweak
$encrypted2 = IpcryptNd::encrypt($ip, $key); // Different result
echo $encrypted1 !== $encrypted2; // true
// Both decrypt to the same IP
$decrypted1 = IpcryptNd::decrypt($encrypted1, $key);
$decrypted2 = IpcryptNd::decrypt($encrypted2, $key);
echo $decrypted1 === $decrypted2; // true
use Ipcrypt\IpcryptNdx;
// Generate a random 32-byte key (two AES-128 keys)
$key = IpcryptNdx::generateKey();
$ip = '192.0.2.1';
// Each encryption produces a different result
$encrypted1 = IpcryptNdx::encrypt($ip, $key); // Uses random 16-byte tweak
$encrypted2 = IpcryptNdx::encrypt($ip, $key); // Different result
echo $encrypted1 !== $encrypted2; // true
// Both decrypt to the same IP
$decrypted1 = IpcryptNdx::decrypt($encrypted1, $key);
$decrypted2 = IpcryptNdx::decrypt($encrypted2, $key);
echo $decrypted1 === $decrypted2; // true
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.