Loading Please wait...

Encryption System

In Zigmoyd Encryption cn be done through 3 kind of drivers or encryption adapter. While using XOR adapter you dont need mcrypt installed. zigmoyd has a minimal XOR based encryption algorithm which is usedif XOR adapter is in use. while using mcrypt you need mcrypt to be installed on your server and the encryption and decryption is done through mcrypt. while using both mcrypt and XOR the string is first encrypted with XOR and then the rsult is further encrypted with mcrypt and abviously you need mcrypt installed in this case also

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
you dont need to bother about which driver you are using or which algorithm or encryption mode or password you are using during encryption. you just set it in the configuration file. and the selected driver is used at the time of encryption.

the frontend of encryption system is the zCrypt Class all other classes are not meant to be used directly.

Configuration

First you need to set which encryption driver you want to use.you do that in etc/sec.ini.php file in your project's directory. your etc/sec.ini.php file might look like the following
[isec]
  driver = z
to set the encryption driver you need to use driver=z, driver=m or driver=b and if you set z you should also do configurations related/specific to that. and if you are using both encryption drivers you need/should to configure both configuration files.

XOR encryption driver

while using XOR adapter you need to modify zcpt.ini.php File.
[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
you can understand what the key directive does by its name.
by using 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. ' ', '+', '_', '*', '&', ':', '-', '@', '=', ''
Note:
First one is a space
However you can change these characters if you want. for that open /usr/include/sec/xor/xor.php file and search near line 42 you will see something like this
$this->val = array(' ', '+', '_', '*', '&', ':', '-', '@', '=', '%');
if you just change it to following the encrypted string will look like an integer stream
$this->val = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
you can change the characters in the array to change the 10 characters.

mcrypt encryption driver

See also:
you dont need to write mcrypt configurations by hand you can use mcrypt.config command to modify your current mcrypt
encryption 
configuration.
if you have choosen mcrypt as the encryption driver you need to modify the 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)
the first three options are very clear to understand. SEC_MCRYPT_IV_SRC is source of randomness in PHP you can use 3 possible sources for randomness among these anly the first one is available to windows cause windows obviously doesn't have /dev/random or /dev/urandom. You generally use 3 constants to specify random's sources. Here you need to specify either 0 or 1 or 2 to specify the randomness source e.g. e.g. if you enter 0 MCRYPT_RAND will be used or if you enter 1 MCRYPT_DEV_URANDOM will be used.
Note:
actually MCRYPT_RAND, MCRYPT_DEV_URANDOM, or MCRYPT_DEV_RANDOM are constants which expands to the integers 0, 1, 2
SEC_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 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


Generated on Mon Oct 27 23:51:57 2008 for zigmoyd.kdevelop by doxygen 1.5.6