Public Member Functions | |
zCryptDrv_xor () | |
__construct () | |
encrypt () | |
Encrypts a string. | |
decrypt () | |
Decrypts a string. | |
Data Fields | |
$key |
can be used when mcrypt is not available
Definition at line 263 of file xor.php.
zCryptDrv_xor::__construct | ( | ) |
Reimplemented from zCryptDrv_xor_intermediate.
Definition at line 269 of file xor.php.
References $key, zCryptDrv_xor_intermediate::$val, and perror().
Referenced by zCryptDrv_xor().
00269 { 00270 parent::__construct(); 00271 $tmp = parse_ini_file(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.ZIGSETTINGSDIR.DRS.'zcpt.ini.php', false); 00272 foreach($tmp as $key => $val){ 00273 if($key != 'key'){ 00274 if($key == "ZCRYPT_DEFAULT_MODE"){ 00275 if($val == "dec"){ 00276 $val = ENC_DEC; 00277 }elseif($val == "bin"){ 00278 $val = ENC_BIN; 00279 }else{ 00280 perror("Invalid ZCRYPT_DEFAULT_MODE ".$val." on ".'zcpt.ini.php'." Must be dec or bin"); 00281 } 00282 } 00283 if(!defined($key)){define($key, $val);} 00284 } 00285 } 00286 $this->key = $tmp['key']; 00287 }
zCryptDrv_xor::zCryptDrv_xor | ( | ) |
Definition at line 266 of file xor.php.
References __construct().
00266 { 00267 $this->__construct(); 00268 }
zCryptDrv_xor::encrypt | ( | ) |
Encrypts a string.
by default it takes the encryption Key/password from the configuration file. However you can pass an additional argument as the key/password with which to encrypt. By default It uses the mode specified in configuration file. However you can specify another mode as an argument. you can use encrypt("string To encrypt", ENC_BIN, "Key to encrypt") or encrypt("string To encrypt", "Key to encrypt", ENC_BIN) both works
$str | String string to Encode | |
$key | mixed Optionally you can specify a key with which to encrypt. | |
$mode | mixed Optionally you can specify Mode of encryption. |
Definition at line 301 of file xor.php.
References $key, zCryptDrv_xor_intermediate::encode(), and perror().
00301 { 00302 $list_args = func_get_args(); 00303 if(@$list_args[1] == null){unset($list_args[1]);} 00304 if(count($list_args) == 0){ 00305 perror("You must supply the string to encrypt as first argument 0 Arguments Given"); 00306 exit(1); 00307 } 00308 if(!is_string($list_args[0])){ 00309 perror("You must supply the string to encrypt as first argument<br />and that should be String ".gettype($list_args[0])." Given"); 00310 exit(1); 00311 } 00312 if(count($list_args) > 3){ 00313 perror("encrypt() requires atleast 1 and atmost 3 arguments ".count($list_args)." given"); 00314 } 00315 if(count($list_args) == 3){ 00316 return $this->encode($list_args[0], $list_args[1], $list_args[2]); 00317 } 00318 if(count($list_args) == 2){ 00319 if(is_string($list_args[1])){ 00320 $key = $list_args[1]; 00321 $mode = ZCRYPT_DEFAULT_MODE; 00322 }elseif(is_bool($list_args[1])){ 00323 $key = $this->key; 00324 $mode = $list_args[1]; 00325 }else{ 00326 perror("2 arguments Given to encrypt() in which second argument is nither MODE nor key rather its ".gettype($list_args[1])." Whos's value is ".$list_args[1]); 00327 } 00328 return $this->encode($list_args[0], $key, $mode); 00329 }else{ 00330 return $this->encode($list_args[0], $this->key, ZCRYPT_DEFAULT_MODE); 00331 } 00332 }
zCryptDrv_xor::decrypt | ( | ) |
Decrypts a string.
by default it takes the encryption Key/password from the configuration File. However you can pass an additional argument as the key/password with which to decrypt(). By default It uses the mode specified in configuration file. However you can specify another mode as an argument. you can use decrypt("string To encrypt", ENC_BIN, "Key to encrypt") or decrypt("string To encrypt", "Key to encrypt", ENC_BIN) both works
$str | String encrypted string to decode | |
$key | mixed Optionally you can specify a key with which to decrypt. | |
$mode | mixed Optionally you can specify Mode of encryption. |
Definition at line 346 of file xor.php.
References $key, zCryptDrv_xor_intermediate::decode(), and perror().
00346 { 00347 $list_args = func_get_args(); 00348 if(@$list_args[1] == null){unset($list_args[1]);} 00349 if(count($list_args) == 0){ 00350 perror("You must supply the string to encrypt as first argument 0 Arguments Given"); 00351 exit(1); 00352 } 00353 if(!is_string($list_args[0])){ 00354 perror("You must supply the string to encrypt as first argument<br />and that should be String ".gettype($list_args[0])." Given"); 00355 exit(1); 00356 } 00357 if(count($list_args) > 3){ 00358 perror("encrypt() requires atleast 1 and atmost 3 arguments ".count($list_args)." given"); 00359 } 00360 if(count($list_args) == 3){ 00361 return $this->decode($list_args[0], $list_args[1], $list_args[2]); 00362 } 00363 if(count($list_args) == 2){ 00364 if(is_string($list_args[1])){ 00365 $key = $list_args[1]; 00366 $mode = ZCRYPT_DEFAULT_MODE; 00367 }elseif(is_bool($list_args[1])){ 00368 $key = $this->key; 00369 $mode = $list_args[1]; 00370 }else{ 00371 perror("2 arguments Given to encrypt() in which second argument is nither MODE nor key"); 00372 } 00373 return $this->decode($list_args[0], $key, $mode); 00374 }else{ 00375 return $this->decode($list_args[0], $this->key, ZCRYPT_DEFAULT_MODE); 00376 } 00377 }
zCryptDrv_xor::$key |