Skip to content
PHP Encryption/Hashing library
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


The sencryption class is a PHP class used to create secure methods of encryption,
decryption, and hashing.  The class is currently version 0.1 which means it may
still be a little buggy and be a little slow.


$data="This is my secure string to be encrypted!";

$enc=new sencryption($key);




echo "Encrypted Data: ".$encrypted."<br>";
echo "Decrypted Data: ".$decrypted;

Within the class there are only 4 useful functions which are described more in detail below.


The load_ciphers function must be called whenever you are going to perform
any type of encryption or decryption.  This function populates the ciphers array
within the class with the needed encryption ciphers.

The $loc variable here is in fact optional (you can leave it blank), or you may
use it to specify the mcrypt library directory within your server or you can use
it to specify a .txt file to read the cipher's from.

NOTE: I would highly recommend loading the cipher's from a .txt file as if you
obtain them from the server or from your mcrypt library's directory they may
change when PHP or the mcrypt library is updated.

Also, the positions of the ciphers within the array MUST remain the same if you
wish to be able to correctly decrypt your data.


This function performs the actual encryption of data. Simply pass data along to
it and it will return the data encrypted.


This function performs the decryption of data.  Pass the encrypted data to this
function and it will return the plain text.


This is the hashing function of the class and will securely hash data that is
passed to it.  The $salt variable is optional, although it is reccommended if
you are using the class simply for encryption.
You can’t perform that action at this time.