<?php
require 'Crypt/Camellia.php';

/* generate initialization vector and key */
$key Crypt_Camellia::generateKey(128);
$iv Crypt_Camellia::generateIV();

/* encryption and decryption in ECB mode */
$c Crypt_Camellia::factory("ecb"$key$iv);
$encrypted $c->encrypt("This is Camellia encryption and decryption.\n");
$decrypted $c->decrypt($encrypted);
echo 
$decrypted;

/* encryption and decryption in CBC mode */
$c Crypt_Camellia::factory("cbc"$key$iv);
$encrypted $c->encrypt("This is Camellia encryption and decryption.\n");
$decrypted $c->decrypt($encrypted);
echo 
$decrypted;

/* encryption and decryption in CFB mode */
$c Crypt_Camellia::factory("cfb"$key$iv);
$encrypted $c->encrypt("This is Camellia encryption and decryption.\n");
$decrypted $c->decrypt($encrypted);
echo 
$decrypted;

/* encryption and decryption in OFB mode */
$c Crypt_Camellia::factory("ofb"$key$iv);
$encrypted $c->encrypt("This is Camellia encryption and decryption.\n");
$decrypted $c->decrypt($encrypted);
echo 
$decrypted;
?>