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.php file in your project's directory. your etc/sec.ini.php file might look like the following [isec] driver = z
z Means Zigmoyd's XOR encryption m means mCrypt and b means 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
key directive does by its name.ZCRYPT_DEFAULT_MODE you can set encryption mode. if encryption mode is set to bin the encrypted string is a binary string.and if dec mode is used you can specify 10 Characters 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.php file 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');
encryption
mcpt.ini.php file. 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_SRC is source of randomness in PHP you can use 3 possible sources for randomness /dev/random /dev/urandomMCRYPT_RAND Systems random number generator MCRYPT_DEV_RANDOM /dev/random MCRYPT_DEV_URANDOM /dev/urandom0 for MCRYPT_RAND 1 for MCRYPT_DEV_URANDOM 2 for MCRYPT_DEV_RANDOMMCRYPT_RAND, MCRYPT_DEV_URANDOM, or MCRYPT_DEV_RANDOM are constants which expands to the integers 0, 1, 2SEC_MCRYPT_TIMEOUT is 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 SEC_MCRYPT_TIMEOUT as s the lifetime will be 1 second and if its m its lifetime will be 1 microsecondif 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
1.5.6