Home > PHP-mcrypt-wrapper-class

PHP-mcrypt-wrapper-class

PHP-mcrypt-wrapper-class is a project mainly written in PHP, it's free.

Wrapper for php mcrypt functions

Simple Usage

require('../Crypt.php')  ;

$options = array(
    'key'       => 'herp derp gerp lerp', # required
    'mode'      => 'ecb',                 # optional
    'algorithm' => 'blowfish',            # optional
    'base64'    => true                   # optional default
);

$crypt = new Crypt($options);

$data = $crypt->encrypt('TOP SECRET blah blah blah');

echo $data; # 13Tt9Omi1uDsWlraXzuHUW6i2O1cySZ6U5dOO7FatCI= 

echo $crypt->decrypt($data); # TOP SECRET blah blah blah

echo $crypt->getMode(); # ecb

echo $crypt->getAlgorithm(); # blowfish

echo $crypt->getBase64Encoding(); # 1

$crypt->close(); # Close

Options

key        => string - (required) no default resized to fit appropriate key size
mode       => must be a result of mcrypt_list_modes() - (optional) default: first result from mcrypt_list_modes()
algorithm  => must be a result of mcrypt_list_algorithms() - (optional) default: first result from mcrypt_list_algorithms()
base64     => bool sets encoding of input/output to base 64 - (optional) default: true

Static Methods

bool Crypt::extensionLoaded()

array Crypt::listOptions()

array Crypt::modes()

array Crypt::algorithms()

Methods

bool __construct(array $params)

string encrypt(string $data)

string decrypt(string $data)

void close()

array listModes()

string getMode()

string setMode(string $mode)

array listAlgorithms()

string getAlgorithm()

string setAlgorithm(string $algorithm)

bool getBase64Encoding()

bool setBase64Encoding(bool $bool)

int listKeySize()

Previous:Wordz