Formatting output Plese Wait...
MCrypt adapter for Zigmoyd Encryption System.
More...
|
Public Member Functions |
| zCryptDrv_mcrypt () |
| __construct () |
| mct () |
| Generates Numbers dependng on Time.
|
| encode ($str, $key=NULL) |
| encodes a string using static IV.
|
| decode ($str, $key=NULL) |
| Decrypts a string which is encrypted using encode() method using static IV.
|
| denc ($str, $key=NULL) |
| encodes a string using Dynamic IV.
|
| ddcd ($str, $key=NULL) |
| decodes a string using dynamic IV.
|
| tenc ($str, $key=NULL) |
| Time based encryption.
|
| tdcd ($str, $key=NULL) |
| decrypts a string thats encoded using tenc() method.
|
| encrypt ($str, $key=NULL) |
| Alias of encode().
|
| decrypt ($str, $key=NULL) |
| Alias of decode().
|
Data Fields |
| $iv |
| $key |
| $iv_size |
| $div |
Detailed Description
MCrypt adapter for Zigmoyd Encryption System.
can be used when mcrypt is available
Definition at line 30 of file mcpt.php.
Constructor & Destructor Documentation
zCryptDrv_mcrypt::__construct( )
Reimplemented from zCore.
Definition at line 39 of file mcpt.php.
References $key, and $val.
Referenced by zCryptDrv_mcrypt().
Show Source00039 {
00040 parent::__construct();
00041 if(!defined('ENC_BIN')){define('ENC_BIN', null);}
00042 if(!defined('ENC_DEC')){define('ENC_DEC', null);}
00043 $tmp_deff = parse_ini_file(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.ZIGSETTINGSDIR.DRS.'mcpt.ini.php', false);
00044 foreach($tmp_deff as $key => $val){
00045 if($key != 'iv' && $key != 'key'){
00046 if(!defined($key)){define($key, $val);}
00047 }
00048 }
00049 $this->iv = base64_decode($tmp_deff['iv']);
00050 $this->key = md5($tmp_deff['mkey']);
00051
00052 $this->iv_size = mcrypt_get_iv_size(SEC_MCRYPT_ALGO, SEC_MCRYPT_MODE);
00053 $this->div = mcrypt_create_iv($this->iv_size, SEC_MCRYPT_IV_SRC);
00054 }
Top
Member Function Documentation
zCryptDrv_mcrypt::zCryptDrv_mcrypt( )
Generates Numbers dependng on Time.
- Returns:
- float
Definition at line 60 of file mcpt.php.
Referenced by tdcd(), and tenc().
Show Source00060 {
00061 list($usec, $sec) = explode(" ", microtime());
00062 return ((float)$usec + (float)$sec);
00063 }
Top
zCryptDrv_mcrypt::encode( string $str, string $key = NULL
)
encodes a string using static IV.
Encrypts a string using mcrypt encryption settings on the configuration files. By default uses the encryption key set on the Configuration files. However you can supply another one through the second optional argument.
- Warning:
- encrypts using Static IV set on Configuration Files.
returns base64 Encoded encrypted string
- Parameters:
-
| $str | string to encode. |
| $key | optionally you can specify a key/password with which to encrypt. |
- Returns:
- string
Definition at line 76 of file mcpt.php.
References $key.
Referenced by encrypt().
Show Source00076 {
00077 if(is_null($key)){$key = $this->key;}
00078 $key_size = mcrypt_get_key_size(SEC_MCRYPT_ALGO, SEC_MCRYPT_MODE);
00079 if(strlen($key) > $key_size){
00080
00081 $key = substr($key, 0, $key_size);
00082 }
00083 return mcrypt_encrypt(SEC_MCRYPT_ALGO, $key, base64_encode($str), SEC_MCRYPT_MODE, $this->iv);
00084 }
Top
zCryptDrv_mcrypt::decode( string $str, string $key = NULL
)
Decrypts a string which is encrypted using encode() method using static IV.
By default uses the encryption key set on the Configuration files. However you can supply another one through the second optional argument.
- Warning:
- encrypts using Static IV set on Configuration Files.
- Parameters:
-
| $str | string to decode. |
| $key | optionally you can specify a key/password with which to decrypt. |
- Returns:
- string
Definition at line 95 of file mcpt.php.
References $key.
Referenced by decrypt().
Show Source00095 {
00096 if(is_null($key)){$key = $this->key;}
00097 $key_size = mcrypt_get_key_size(SEC_MCRYPT_ALGO, SEC_MCRYPT_MODE);
00098 if(strlen($key) > $key_size){
00099
00100 $key = substr($key, 0, $key_size);
00101 }
00102
00103 return base64_decode(trim(@mcrypt_decrypt(SEC_MCRYPT_ALGO, $key, $str, SEC_MCRYPT_MODE, $this->iv)));
00104 }
Top
zCryptDrv_mcrypt::denc( string $str, string $key = NULL
)
encodes a string using Dynamic IV.
Encrypts a string using mcrypt encryption settings on the configuration files. By default uses the encryption key set on the Configuration files. However you can supply another one through the second optional argument.
- Warning:
- remember It uses a dynamically generated IV so it doesn't uses the IV set on configuration file(s)
The Dynamic IV used for this encryption is created only once in an Internal Instance. so if you call denc() multiple times it will use NOT different IVs. but when denc() is called on another request it will use a different IV. e.g. When Zigmoyd gets a HTTP requests it generates a dynamic IV which will be used for that Session only. whenever that session is gone and a new Request arrives another Dynamic IV is generated for that session. so all calls to denc() in same session will use the same dynami IV.
returns base64 Encoded encrypted string
- Parameters:
-
| $str | string to encode. |
| $key | optionally you can specify a key/password with which to encrypt. |
- Returns:
- string
Definition at line 121 of file mcpt.php.
References $key.
Show Source00121 {
00122 if(is_null($key)){$key = $this->key;}
00123 $key_size = mcrypt_get_key_size(SEC_MCRYPT_ALGO, SEC_MCRYPT_MODE);
00124 if(strlen($key) > $key_size){
00125
00126 $key = substr($key, 0, $key_size);
00127 }
00128 return mcrypt_encrypt(SEC_MCRYPT_ALGO, $key, base64_encode($str), SEC_MCRYPT_MODE, $this->div);
00129 }
Top
zCryptDrv_mcrypt::ddcd( string $str, string $key = NULL
)
decodes a string using dynamic IV.
decodes a string which has been encoded using denc()
- See also:
- denc()
- Parameters:
-
| $str | string to decode. |
| $key | optionally you can specify a key/password with which to decrypt. |
- Returns:
- string
Definition at line 139 of file mcpt.php.
References $key.
Show Source00139 {
00140 if(is_null($key)){$key = $this->key;}
00141 $key_size = mcrypt_get_key_size(SEC_MCRYPT_ALGO, SEC_MCRYPT_MODE);
00142 if(strlen($key) > $key_size){
00143
00144 $key = substr($key, 0, $key_size);
00145 }
00146 return trim(base64_decode(mcrypt_decrypt(SEC_MCRYPT_ALGO, $key, $str, SEC_MCRYPT_MODE, $this->div)));
00147 }
Top
zCryptDrv_mcrypt::tenc( string $str, string $key = NULL
)
Time based encryption.
Concates the encryption key/password with Current Time String. the Time String can be in second or Microsecond based on your Configuration settings. if its set to microsecond the encrypted string is valid for 1 microsecond only. and if its set it second the encrypted string is valid for 1 second only. by defalut takes encryption key/password from the configuration file. However you can optionally supply key with which to encrypt.
- Parameters:
-
| $str | string that to encode |
| $key | optionally key/password with which to encode |
- Returns:
- string
Definition at line 161 of file mcpt.php.
References $key, and mct().
Show Source00161 {
00162 if(is_null($key)){$key = $this->key;}
00163 $key_size = mcrypt_get_key_size(SEC_MCRYPT_ALGO, SEC_MCRYPT_MODE);
00164 if(strlen($key) > $key_size){
00165
00166 $key = substr($key, 0, $key_size);
00167 }
00168 if(SEC_MCRYPT_TIMEOUT == 'm'){$t = time();}elseif(SEC_MCRYPT_TIMEOUT == 's'){$t = $this->mct();}
00169 return mcrypt_encrypt(SEC_MCRYPT_ALGO, $key.$t, base64_encode($str), SEC_MCRYPT_MODE, $this->div);
00170 }
Top
zCryptDrv_mcrypt::tdcd( string $str, string $key = NULL
)
decrypts a string thats encoded using tenc() method.
- See also:
- tenc()
- Parameters:
-
| $str | string that to decode |
| $key | optionally key/password with which to decode |
- Returns:
- string
Definition at line 179 of file mcpt.php.
References $key, and mct().
Show Source00179 {
00180 if(is_null($key)){$key = $this->key;}
00181 $key_size = mcrypt_get_key_size(SEC_MCRYPT_ALGO, SEC_MCRYPT_MODE);
00182 if(strlen($key) > $key_size){
00183
00184 $key = substr($key, 0, $key_size);
00185 }
00186 if(SEC_MCRYPT_TIMEOUT == 'm'){$t = time();}elseif(SEC_MCRYPT_TIMEOUT == 's'){$t = $this->mct();}
00187
00188 return base64_decode(trim(mcrypt_decrypt(SEC_MCRYPT_ALGO, $key.$t, $str, SEC_MCRYPT_MODE, $this->div)));
00189 }
Top
zCryptDrv_mcrypt::encrypt( string $str, string $key = NULL
)
Alias of encode().
- See also:
- encode()
- Parameters:
-
| $str | String that yo want to encode. |
| $key | key with which you want to decode. |
- Returns:
- string
Definition at line 198 of file mcpt.php.
References $key, and encode().
Show Source00198 {
00199 return $this->encode($str, $key);
00200 }
Top
zCryptDrv_mcrypt::decrypt( string $str, string $key = NULL
)
Alias of decode().
- See also:
- decode()
- Parameters:
-
| $str | Sencrypted string that you want to decode. |
| $key | key with which you want to decode. |
- Returns:
- string
Definition at line 209 of file mcpt.php.
References $key, and decode().
Show Source00209 {
00210 return $this->decode($str, $key);
00211 }
Top
Field Documentation
zCryptDrv_mcrypt::$iv_size
The documentation for this class was generated from the following file: