Update of /cvsroot/easymod/easymod/install/em_files/includes/em
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3720
Modified Files:
em_crypt.php
Log Message:
updating encryption methods to what is in the current release.
Index: em_crypt.php
===================================================================
RCS file: /cvsroot/easymod/easymod/install/em_files/includes/em/em_crypt.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** em_crypt.php 4 Dec 2005 03:12:30 -0000 1.1
--- em_crypt.php 6 Dec 2005 23:41:07 -0000 1.2
***************
*** 528,532 ****
{
$this->setkey($key);
!
$encrypted = '';
--- 528,532 ----
{
$this->setkey($key);
!
$encrypted = '';
***************
*** 549,556 ****
// added by Nuttzy - we'll be storing the result in a DB so we need to replace ' with \'
! $encrypted = addslashes($encrypted) ;
// TAKE TWO: the way General Config settings work in phpBB, this isn't sufficient, get rid of the ' all together
! $encrypted = str_replace("\'", "NUTTICK", $encrypted);
! $encrypted = str_replace("\n", 'NUTLINE', $encrypted);
// NOTE: a cipher of "single'quote" (the cipher is the stuff between the double quotes) has the ' changed
--- 549,556 ----
// added by Nuttzy - we'll be storing the result in a DB so we need to replace ' with \'
! // $encrypted = addslashes($encrypted);
// TAKE TWO: the way General Config settings work in phpBB, this isn't sufficient, get rid of the ' all together
! // $encrypted = str_replace("\'", 'NUTTICK', $encrypted);
! // $encrypted = str_replace("\n", 'NUTLINE', $encrypted);
// NOTE: a cipher of "single'quote" (the cipher is the stuff between the double quotes) has the ' changed
***************
*** 558,568 ****
// all just so the string is formed properly and what actually gets stored in the DB is "single'quote". The
// same is true for any slashes that get added. The slashes won't actually show up when viewing the DB ;-)
-
- // change encoding for storage (postgres problems)
- $encrypted = @utf8_encode($encrypted);
-
- return $encrypted ;
- }
// decrypts the cipher a chunk at a time and returns the plaintext
--- 558,568 ----
// all just so the string is formed properly and what actually gets stored in the DB is "single'quote". The
// same is true for any slashes that get added. The slashes won't actually show up when viewing the DB ;-)
+ // TAKE THREE: Hopefully the new hex2bin/bin2hex methods solve all these problems.
+ // change encoding for storage (postgres problems with binary string)
+ $encrypted = $this->bin2hex($encrypted);
+
+ return $encrypted;
+ }
// decrypts the cipher a chunk at a time and returns the plaintext
***************
*** 570,580 ****
{
$this->setkey($key);
!
! // decode for use (postgres storage problems)
! $ciphertext = @utf8_decode($ciphertext);
// TAKE TWO: the way General Config settings work in phpBB, this isn't sufficient, get rid of the ' all together
! $ciphertext = str_replace('NUTTICK', "'", $ciphertext);
! $ciphertext = str_replace('NUTLINE', "\n", $ciphertext);
$decrypted = '';
--- 570,581 ----
{
$this->setkey($key);
!
! // TAKE THREE: Hopefully the new hex2bin/bin2hex methods solve all these problems.
! // decode for use (postgres storage problems with binary string)
! $ciphertext = $this->hex2bin($ciphertext);
// TAKE TWO: the way General Config settings work in phpBB, this isn't sufficient, get rid of the ' all together
! // $ciphertext = str_replace('NUTTICK', "'", $ciphertext);
! // $ciphertext = str_replace('NUTLINE', "\n", $ciphertext);
$decrypted = '';
***************
*** 594,598 ****
$decrypted = substr($decrypted, 0, -1);
}
!
return $decrypted;
}
--- 595,599 ----
$decrypted = substr($decrypted, 0, -1);
}
!
return $decrypted;
}
***************
*** 608,611 ****
--- 609,632 ----
return;
}
+
+ // convert a binary string into an hexadecimal string
+ function bin2hex($bin)
+ {
+ for( $hex = '', $i = 0, $length = strlen($bin); $i < $length; $i++ )
+ {
+ $hex .= substr('0' . dechex(ord($bin[$i])), -2);
+ }
+ return $hex;
+ }
+
+ // convert an hexadecimal string into a binary string
+ function hex2bin($hex)
+ {
+ for( $bin = '', $i = 0, $length = strlen($hex); $i < $length; $i=$i+2 )
+ {
+ $bin .= chr(hexdec(substr($hex, $i, 2)));
+ }
+ return $bin;
+ }
}
|