|
|
|
@ -7,18 +7,18 @@ Class Cryptography
@@ -7,18 +7,18 @@ Class Cryptography
|
|
|
|
|
if (is_file($source) === true) |
|
|
|
|
{ |
|
|
|
|
$source = file_get_contents($source); |
|
|
|
|
switch($cipher) |
|
|
|
|
{ |
|
|
|
|
case 'tripleDES': |
|
|
|
|
$encryptedSource=$this->TripleDesEncrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
case 'AES': |
|
|
|
|
$encryptedSource=$this->AESEncrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
$encryptedSource=$this->TripleDesEncrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
switch($cipher) |
|
|
|
|
{ |
|
|
|
|
case 'tripleDES': |
|
|
|
|
$encryptedSource=$this->TripleDesEncrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
case 'AES': |
|
|
|
|
$encryptedSource=$this->AESEncrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
$encryptedSource=$this->TripleDesEncrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (file_put_contents($destination,$encryptedSource, LOCK_EX) !== false) |
|
|
|
|
{ |
|
|
|
|
return true; |
|
|
|
@ -37,18 +37,18 @@ Class Cryptography
@@ -37,18 +37,18 @@ Class Cryptography
|
|
|
|
|
if (is_file($source) === true) |
|
|
|
|
{ |
|
|
|
|
$source = file_get_contents($source); |
|
|
|
|
switch($cipher) |
|
|
|
|
{ |
|
|
|
|
case 'tripleDES': |
|
|
|
|
$decryptedSource=self::TripleDesDecrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
case 'AES': |
|
|
|
|
$decryptedSource=self::AESDecrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
$decryptedSource=self::TripleDesDecrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
switch($cipher) |
|
|
|
|
{ |
|
|
|
|
case 'tripleDES': |
|
|
|
|
$decryptedSource=self::TripleDesDecrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
case 'AES': |
|
|
|
|
$decryptedSource=self::AESDecrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
$decryptedSource=self::TripleDesDecrypt($source,$key,$iv); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (file_put_contents($destination,$decryptedSource, LOCK_EX) !== false) |
|
|
|
|
{ |
|
|
|
|
return true; |
|
|
|
@ -81,8 +81,8 @@ Class Cryptography
@@ -81,8 +81,8 @@ Class Cryptography
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
mcrypt_generic_init($cipher, $key, $iv); |
|
|
|
|
$result = mcrypt_generic($cipher, $buffer); |
|
|
|
|
mcrypt_generic_deinit($cipher); |
|
|
|
|
$result = mcrypt_generic($cipher, $buffer); |
|
|
|
|
mcrypt_generic_deinit($cipher); |
|
|
|
|
return base64_encode($result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -113,13 +113,13 @@ Class Cryptography
@@ -113,13 +113,13 @@ Class Cryptography
|
|
|
|
|
$extra = 8 - (strlen($buffer) % 8); |
|
|
|
|
// add the zero padding |
|
|
|
|
if($extra > 0) { |
|
|
|
|
for($i = 0; $i < $extra; $i++) { |
|
|
|
|
$buffer .= '_'; |
|
|
|
|
for($i = 0; $i < $extra; $i++) { |
|
|
|
|
$buffer .= '_'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
mcrypt_generic_init($cipher, $key, $iv); |
|
|
|
|
$result = mcrypt_generic($cipher, $buffer); |
|
|
|
|
mcrypt_generic_deinit($cipher); |
|
|
|
|
mcrypt_generic_init($cipher, $key, $iv); |
|
|
|
|
$result = mcrypt_generic($cipher, $buffer); |
|
|
|
|
mcrypt_generic_deinit($cipher); |
|
|
|
|
return base64_encode($result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -133,9 +133,9 @@ Class Cryptography
@@ -133,9 +133,9 @@ Class Cryptography
|
|
|
|
|
$cipher = mcrypt_module_open('rijndael-256', '', 'cbc', ''); |
|
|
|
|
mcrypt_generic_init($cipher, $key, $iv); |
|
|
|
|
$result = mdecrypt_generic($cipher,$buffer); |
|
|
|
|
$result=substr($result,0,strpos($result,'___EOT')); |
|
|
|
|
$result=substr($result,0,strpos($result,'___EOT')); |
|
|
|
|
mcrypt_generic_deinit($cipher); |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
?> |
|
|
|
|
?> |
|
|
|
|