PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Name Removed   PHP AES-128-CBC Encryption and Decryption   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: PHP AES-128-CBC Encryption and Decryption
Encrypt and decrypt data using mcrypt
Author: By
Last change: Made the source code more clear.
Date: 7 years ago
Size: 624 bytes
 

Contents

Class file image Download
<?php

/****
****
*** @ PHP AES-128-CBC class
*** @ Developed by Takis Maletsas
****
****/

require "aes.class.php";

$aes = new AES;
$aes->setData("Hello world !");

$encrypted = $aes->encrypt();

//You can use setKey() and setIV() in the encryption process.
//If you don't, the class will produce random key and IV.
//You can get them with getKey() and getIV().

$aes->setKey($aes->getKey());
$aes->setIV($aes->getIV());
$aes->setData($encrypted);

$decrypted = $aes->decrypt();

echo
$encrypted . "<br/>" . $decrypted;

//Encrypted: hibcqPrxD0rv2E5b5/LzYQ==
//Decrypted: Hello world !

?>