you will just invoke zCrypt::encode("Hello World"); and the string "Hello World" will be encrypted with the encryption configuration. it will be encrypted using the encryption driver specified in the encryption configuration files.
$name = "Foo Bar"; $encryptedName = zCrypt::encode($name);//encryption $decryptedName = zCrypt::decode($encryptedName);//decryption Retriving the original text from the encrypted one
the frontend of encryption system is the zCrypt Class all other classes are not meant to be used directly.
etc/sec.ini.phpfile in your project's directory. your
etc/sec.ini.phpfile might look like the following
[isec] driver = z
zMeans Zigmoyd's XOR encryption
mmeans mCrypt and
bmeans both one after another
[zcpt] key = "mySecretKey";Set the encryption Key e.g. secret Password ZCRYPT_DEFAULT_MODE = "bin";Set the encryption mode binary by default.you can make it dec (decimal) too
keydirective does by its name.
ZCRYPT_DEFAULT_MODEyou can set encryption mode. if encryption mode is set to
binthe encrypted string is a binary string.and if
decmode is used you can specify
10Characters only those characters will be used in the resulting. e.g. your encrypted string will only contain a combination of those 10 characters that you have choosen. by default the following 10 characters are used.
' ', '+', '_', '*', '&', ':', '-', '@', '=', ''
/usr/include/sec/xor/xor.phpfile and search near line 42 you will see something like this
$this->val = array(' ', '+', '_', '*', '&', ':', '-', '@', '=', '%');
$this->val = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
mcpt.ini.phpfile. its content might look like the following.
[mcrypt] SEC_MCRYPT_ALGO = blowfish-compat;mcrypt algorithm to use SEC_MCRYPT_MODE = cbc;mcrypt encryption mode to use mkey = "mySecretKey";password used for encryption SEC_MCRYPT_IV_SRC = 0;IV Source SEC_MCRYPT_TIMEOUT = s;timeout iv = "PeiYyjHqAyk=";IV (Initialization vector)
SEC_MCRYPT_IV_SRCis source of randomness in PHP you can use 3 possible sources for randomness
MCRYPT_RANDSystems random number generator
MCRYPT_DEV_RANDOMare constants which expands to the integers 0, 1, 2
SEC_MCRYPT_TIMEOUTis the timeout settings it is important when you use zCrypt::tenc() and friends where each encrypted string is only valid upto 1 second or 1 microsecond e.g. if you dont decrypt it within 1 second or 1 microsecond it can not be decrypted. If you specify value of
sthe lifetime will be 1 second and if its
mits lifetime will be 1 microsecond
if you are using such a mode for encryption that doesn't require an IV (initialization vector) you dont need to bother about this section Zigmoyd lets you encrypt with mcrypt with static or dynamic IV, when its encrypted with static Iv its IV is stored in the configuration file. and when you are using dynamic IV zCrypt::menc() the stored IV is not used and each timne a new IV is generated. when you are using static IV if you forget the IV or loose the IV you cannot decrypt already encrypted string. in case of encryption with dynamic IV a new IV is dynamically generated for each session and all encryption and decryption which is done through zCrypt::denc() or zCrypt::ddcd() is done through that IV.
when you use mcrypt.config command to modify the mcrypt configuration it will genarate the static Iv