PHP code example of ivinco / crypto-ff3

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

    

ivinco / crypto-ff3 example snippets


use Ivinco\Crypto\FF3Cipher;

$key = "EF4359D8D580AA4F7F036D6F04FC6A94"; // Your encryption key
$tweak = "D8E7920AFA330A73"; // Your tweak

$cipher = new FF3Cipher($key, $tweak);

$plaintext = "1234567890";
$ciphertext = $cipher->encrypt($plaintext);
echo "Ciphertext: " . $ciphertext . PHP_EOL;

$decrypted = $cipher->decrypt($ciphertext);
echo "Decrypted: " . $decrypted . PHP_EOL;

$alphabet = "abcdefghijklmnopqrstuvwxyz"; // Custom alphabet
$cipher = FF3Cipher::withCustomAlphabet($key, $tweak, $alphabet);

$plaintext = "wfmwlrorcd";
$ciphertext = $cipher->encrypt($plaintext);
echo "Ciphertext: " . $ciphertext . PHP_EOL; // ywowehycyd

$decrypted = $cipher->decrypt($ciphertext); // wfmwlrorcd
echo "Decrypted: " . $decrypted . PHP_EOL;