summaryrefslogtreecommitdiff
path: root/inc/blowfish.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2010-01-29 13:57:24 +0100
committerAndreas Gohr <andi@splitbrain.org>2010-01-29 13:57:24 +0100
commit0b17fdc6719c24850fa7095bc33f292f97f4ec02 (patch)
tree78c3684ced344d8cbe640228c889636b16a8d0d3 /inc/blowfish.php
parentc4cf0c4a8bff66d710b95fce6199aa4beca81d30 (diff)
downloadrpg-0b17fdc6719c24850fa7095bc33f292f97f4ec02.tar.gz
rpg-0b17fdc6719c24850fa7095bc33f292f97f4ec02.tar.bz2
more code cleanup according to coding standard
Diffstat (limited to 'inc/blowfish.php')
-rw-r--r--inc/blowfish.php55
1 files changed, 24 insertions, 31 deletions
diff --git a/inc/blowfish.php b/inc/blowfish.php
index 42e3a589a..bcf5804a2 100644
--- a/inc/blowfish.php
+++ b/inc/blowfish.php
@@ -299,8 +299,7 @@ class Horde_Cipher_blowfish
*
* @param String $key The key to use
*/
- function setKey($key)
- {
+ function setKey($key) {
$key = $this->_formatKey($key);
$keyPos = $keyXor = 0;
@@ -318,37 +317,37 @@ class Horde_Cipher_blowfish
$encZero = array('L' => 0, 'R' => 0);
for ($i = 0; $i + 1 < $iMax; $i += 2) {
- $encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
- $this->p[$i] = $encZero['L'];
- $this->p[$i + 1] = $encZero['R'];
+ $encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
+ $this->p[$i] = $encZero['L'];
+ $this->p[$i + 1] = $encZero['R'];
}
$iMax = count($this->s1);
for ($i = 0; $i < $iMax; $i += 2) {
- $encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
- $this->s1[$i] = $encZero['L'];
- $this->s1[$i + 1] = $encZero['R'];
+ $encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
+ $this->s1[$i] = $encZero['L'];
+ $this->s1[$i + 1] = $encZero['R'];
}
$iMax = count($this->s2);
for ($i = 0; $i < $iMax; $i += 2) {
- $encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
- $this->s2[$i] = $encZero['L'];
- $this->s2[$i + 1] = $encZero['R'];
+ $encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
+ $this->s2[$i] = $encZero['L'];
+ $this->s2[$i + 1] = $encZero['R'];
}
$iMax = count($this->s3);
for ($i = 0; $i < $iMax; $i += 2) {
- $encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
- $this->s3[$i] = $encZero['L'];
- $this->s3[$i + 1] = $encZero['R'];
+ $encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
+ $this->s3[$i] = $encZero['L'];
+ $this->s3[$i + 1] = $encZero['R'];
}
$iMax = count($this->s4);
for ($i = 0; $i < $iMax; $i += 2) {
- $encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
- $this->s4[$i] = $encZero['L'];
- $this->s4[$i + 1] = $encZero['R'];
+ $encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
+ $this->s4[$i] = $encZero['L'];
+ $this->s4[$i + 1] = $encZero['R'];
}
}
@@ -361,8 +360,7 @@ class Horde_Cipher_blowfish
*
* @return String the encrypted output
*/
- function encryptBlock($block, $key = null)
- {
+ function encryptBlock($block, $key = null) {
if (!is_null($key)) {
$this->setKey($key);
}
@@ -380,8 +378,7 @@ class Horde_Cipher_blowfish
*
* @return String The encrypted output.
*/
- function _encryptBlock($L, $R)
- {
+ function _encryptBlock($L, $R) {
$L ^= $this->p[0];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[1];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[2];
@@ -412,13 +409,12 @@ class Horde_Cipher_blowfish
*
* @return String the decrypted output
*/
- function decryptBlock($block, $key = null)
- {
+ function decryptBlock($block, $key = null) {
if (!is_null($key)) {
$this->setKey($key);
}
-// change for phpMyAdmin
+ // change for phpMyAdmin
$L = null;
$R = null;
@@ -429,7 +425,7 @@ class Horde_Cipher_blowfish
if (isset($retarray[1])) {
$R = $retarray[1];
}
-// end change for phpMyAdmin
+ // end change for phpMyAdmin
$L ^= $this->p[17];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[16];
@@ -458,8 +454,7 @@ class Horde_Cipher_blowfish
*
* @return array The key.
*/
- function _formatKey($key)
- {
+ function _formatKey($key) {
return array_values(unpack('C*', $key));
}
@@ -478,8 +473,7 @@ class Horde_Cipher_blowfish
*
* @author lem9
*/
-function PMA_blowfish_encrypt($data, $secret)
-{
+function PMA_blowfish_encrypt($data, $secret) {
$pma_cipher = new Horde_Cipher_blowfish;
$encrypt = '';
@@ -508,8 +502,7 @@ function PMA_blowfish_encrypt($data, $secret)
*
* @author lem9
*/
-function PMA_blowfish_decrypt($encdata, $secret)
-{
+function PMA_blowfish_decrypt($encdata, $secret) {
$pma_cipher = new Horde_Cipher_blowfish;
$decrypt = '';
$data = base64_decode($encdata);