Completed
Push — development ( 362b6c...477849 )
by Nils
08:04
created
includes/libraries/phpcrypt/modes/NOFB.php 3 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -37,128 +37,128 @@
 block discarded – undo
37 37
  */
38 38
 class Mode_NOFB extends Mode
39 39
 {
40
-	/**
41
-	 * Constructor
42
-	 * Sets the cipher object that will be used for encryption
43
-	 *
44
-	 * @param object $cipher one of the phpCrypt encryption cipher objects
45
-	 * @return void
46
-	 */
47
-	public function __construct($cipher)
48
-	{
49
-		parent::__construct(PHP_Crypt::MODE_NOFB, $cipher);
50
-
51
-		// this works with only block Ciphers
52
-		if($cipher->type() != Cipher::BLOCK)
53
-			trigger_error("NOFB mode requires a block cipher", E_USER_WARNING);
54
-	}
55
-
56
-
57
-	/**
58
-	 * Destructor
59
-	 *
60
-	 * @return void
61
-	 */
62
-	public function __destruct()
63
-	{
64
-		parent::__destruct();
65
-	}
66
-
67
-
68
-	/**
69
-	 * Encrypts an the entire string $plain_text using the cipher passed
70
-	 *
71
-	 * @param string $text the string to be encrypted
72
-	 * @return boolean Returns true
73
-	 */
74
-	public function encrypt(&$text)
75
-	{
76
-		$len = strlen($text);
77
-		$blocksz = $this->cipher->blockSize();
78
-
79
-		$max = $len / $blocksz;
80
-		for($i = 0; $i < $max; ++$i)
81
-		{
82
-			// current position in the text
83
-			$pos = $i * $blocksz;
84
-
85
-			// make sure we don't extend past the length of $text
86
-			$byte_len = $blocksz;
87
-			if(($pos + $blocksz) > $len)
88
-				$byte_len -= ($pos + $blocksz) - $len;
89
-
90
-			// encrypt the register
91
-			$this->enc_register = $this->register;
92
-			$this->cipher->encrypt($this->enc_register);
93
-
94
-			// now grab a block of text and a block of from the register, and XOR them
95
-			$block = substr($text, $pos, $byte_len);
96
-			for($j = 0; $j < $byte_len; ++$j)
97
-				$block[$j] = $block[$j] ^ $this->enc_register[$j];
98
-
99
-			// replace the plain text block with encrypted text
100
-			$text = substr_replace($text, $block, $pos, $byte_len);
101
-
102
-			// shift the register left n-bytes, append n-bytes of encrypted register
103
-			$this->register = substr($this->register, $byte_len);
104
-			$this->register .= substr($this->enc_register, 0, $byte_len);
105
-		}
106
-
107
-		return true;
108
-	}
109
-
110
-
111
-	/**
112
-	 * Decrypts an the entire string $plain_text using the cipher passed
113
-	 *
114
-	 * @param string $text the string to be decrypted
115
-	 * @return boolean Returns true
116
-	 */
117
-	public function decrypt(&$text)
118
-	{
119
-		$len = strlen($text);
120
-		$blocksz = $this->cipher->blockSize();
121
-
122
-		$max = $len / $blocksz;
123
-		for($i = 0; $i < $max; ++$i)
124
-		{
125
-			// current position within $text
126
-			$pos = $i * $blocksz;
127
-
128
-			// make sure we don't extend past the length of $text
129
-			$byte_len = $blocksz;
130
-			if(($pos + $byte_len) > $len)
131
-				$byte_len -= ($pos + $byte_len) - $len;
132
-
133
-			// encrypt the register
134
-			$this->enc_register = $this->register;
135
-			$this->cipher->encrypt($this->enc_register);
136
-
137
-			// shift the register left n-bytes, append n-bytes of encrypted register
138
-			$this->register = substr($this->register, $byte_len);
139
-			$this->register .= substr($this->enc_register, 0, $byte_len);
140
-
141
-			// now grab a block of text and xor with the register
142
-			$block = substr($text, $pos, $byte_len);
143
-			for($j = 0; $j < $byte_len; ++$j)
144
-				$block[$j] = $block[$j] ^ $this->enc_register[$j];
145
-
146
-			// replace the encrypted block with plain text
147
-			$text = substr_replace($text, $block, $pos, $byte_len);
148
-		}
149
-
150
-		return true;
151
-	}
152
-
153
-
154
-	/**
155
-	 * This mode requires an IV
156
-	 *
157
-	 * @return boolean true
158
-	 */
159
-	public function requiresIV()
160
-	{
161
-		return true;
162
-	}
40
+    /**
41
+     * Constructor
42
+     * Sets the cipher object that will be used for encryption
43
+     *
44
+     * @param object $cipher one of the phpCrypt encryption cipher objects
45
+     * @return void
46
+     */
47
+    public function __construct($cipher)
48
+    {
49
+        parent::__construct(PHP_Crypt::MODE_NOFB, $cipher);
50
+
51
+        // this works with only block Ciphers
52
+        if($cipher->type() != Cipher::BLOCK)
53
+            trigger_error("NOFB mode requires a block cipher", E_USER_WARNING);
54
+    }
55
+
56
+
57
+    /**
58
+     * Destructor
59
+     *
60
+     * @return void
61
+     */
62
+    public function __destruct()
63
+    {
64
+        parent::__destruct();
65
+    }
66
+
67
+
68
+    /**
69
+     * Encrypts an the entire string $plain_text using the cipher passed
70
+     *
71
+     * @param string $text the string to be encrypted
72
+     * @return boolean Returns true
73
+     */
74
+    public function encrypt(&$text)
75
+    {
76
+        $len = strlen($text);
77
+        $blocksz = $this->cipher->blockSize();
78
+
79
+        $max = $len / $blocksz;
80
+        for($i = 0; $i < $max; ++$i)
81
+        {
82
+            // current position in the text
83
+            $pos = $i * $blocksz;
84
+
85
+            // make sure we don't extend past the length of $text
86
+            $byte_len = $blocksz;
87
+            if(($pos + $blocksz) > $len)
88
+                $byte_len -= ($pos + $blocksz) - $len;
89
+
90
+            // encrypt the register
91
+            $this->enc_register = $this->register;
92
+            $this->cipher->encrypt($this->enc_register);
93
+
94
+            // now grab a block of text and a block of from the register, and XOR them
95
+            $block = substr($text, $pos, $byte_len);
96
+            for($j = 0; $j < $byte_len; ++$j)
97
+                $block[$j] = $block[$j] ^ $this->enc_register[$j];
98
+
99
+            // replace the plain text block with encrypted text
100
+            $text = substr_replace($text, $block, $pos, $byte_len);
101
+
102
+            // shift the register left n-bytes, append n-bytes of encrypted register
103
+            $this->register = substr($this->register, $byte_len);
104
+            $this->register .= substr($this->enc_register, 0, $byte_len);
105
+        }
106
+
107
+        return true;
108
+    }
109
+
110
+
111
+    /**
112
+     * Decrypts an the entire string $plain_text using the cipher passed
113
+     *
114
+     * @param string $text the string to be decrypted
115
+     * @return boolean Returns true
116
+     */
117
+    public function decrypt(&$text)
118
+    {
119
+        $len = strlen($text);
120
+        $blocksz = $this->cipher->blockSize();
121
+
122
+        $max = $len / $blocksz;
123
+        for($i = 0; $i < $max; ++$i)
124
+        {
125
+            // current position within $text
126
+            $pos = $i * $blocksz;
127
+
128
+            // make sure we don't extend past the length of $text
129
+            $byte_len = $blocksz;
130
+            if(($pos + $byte_len) > $len)
131
+                $byte_len -= ($pos + $byte_len) - $len;
132
+
133
+            // encrypt the register
134
+            $this->enc_register = $this->register;
135
+            $this->cipher->encrypt($this->enc_register);
136
+
137
+            // shift the register left n-bytes, append n-bytes of encrypted register
138
+            $this->register = substr($this->register, $byte_len);
139
+            $this->register .= substr($this->enc_register, 0, $byte_len);
140
+
141
+            // now grab a block of text and xor with the register
142
+            $block = substr($text, $pos, $byte_len);
143
+            for($j = 0; $j < $byte_len; ++$j)
144
+                $block[$j] = $block[$j] ^ $this->enc_register[$j];
145
+
146
+            // replace the encrypted block with plain text
147
+            $text = substr_replace($text, $block, $pos, $byte_len);
148
+        }
149
+
150
+        return true;
151
+    }
152
+
153
+
154
+    /**
155
+     * This mode requires an IV
156
+     *
157
+     * @return boolean true
158
+     */
159
+    public function requiresIV()
160
+    {
161
+        return true;
162
+    }
163 163
 }
164 164
 ?>
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		parent::__construct(PHP_Crypt::MODE_NOFB, $cipher);
50 50
 
51 51
 		// this works with only block Ciphers
52
-		if($cipher->type() != Cipher::BLOCK)
52
+		if ($cipher->type() != Cipher::BLOCK)
53 53
 			trigger_error("NOFB mode requires a block cipher", E_USER_WARNING);
54 54
 	}
55 55
 
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		$blocksz = $this->cipher->blockSize();
78 78
 
79 79
 		$max = $len / $blocksz;
80
-		for($i = 0; $i < $max; ++$i)
80
+		for ($i = 0; $i < $max; ++$i)
81 81
 		{
82 82
 			// current position in the text
83 83
 			$pos = $i * $blocksz;
84 84
 
85 85
 			// make sure we don't extend past the length of $text
86 86
 			$byte_len = $blocksz;
87
-			if(($pos + $blocksz) > $len)
87
+			if (($pos + $blocksz) > $len)
88 88
 				$byte_len -= ($pos + $blocksz) - $len;
89 89
 
90 90
 			// encrypt the register
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 			// now grab a block of text and a block of from the register, and XOR them
95 95
 			$block = substr($text, $pos, $byte_len);
96
-			for($j = 0; $j < $byte_len; ++$j)
96
+			for ($j = 0; $j < $byte_len; ++$j)
97 97
 				$block[$j] = $block[$j] ^ $this->enc_register[$j];
98 98
 
99 99
 			// replace the plain text block with encrypted text
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
 		$blocksz = $this->cipher->blockSize();
121 121
 
122 122
 		$max = $len / $blocksz;
123
-		for($i = 0; $i < $max; ++$i)
123
+		for ($i = 0; $i < $max; ++$i)
124 124
 		{
125 125
 			// current position within $text
126 126
 			$pos = $i * $blocksz;
127 127
 
128 128
 			// make sure we don't extend past the length of $text
129 129
 			$byte_len = $blocksz;
130
-			if(($pos + $byte_len) > $len)
130
+			if (($pos + $byte_len) > $len)
131 131
 				$byte_len -= ($pos + $byte_len) - $len;
132 132
 
133 133
 			// encrypt the register
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
 			// now grab a block of text and xor with the register
142 142
 			$block = substr($text, $pos, $byte_len);
143
-			for($j = 0; $j < $byte_len; ++$j)
143
+			for ($j = 0; $j < $byte_len; ++$j)
144 144
 				$block[$j] = $block[$j] ^ $this->enc_register[$j];
145 145
 
146 146
 			// replace the encrypted block with plain text
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -49,8 +49,9 @@  discard block
 block discarded – undo
49 49
 		parent::__construct(PHP_Crypt::MODE_NOFB, $cipher);
50 50
 
51 51
 		// this works with only block Ciphers
52
-		if($cipher->type() != Cipher::BLOCK)
53
-			trigger_error("NOFB mode requires a block cipher", E_USER_WARNING);
52
+		if($cipher->type() != Cipher::BLOCK) {
53
+					trigger_error("NOFB mode requires a block cipher", E_USER_WARNING);
54
+		}
54 55
 	}
55 56
 
56 57
 
@@ -84,8 +85,9 @@  discard block
 block discarded – undo
84 85
 
85 86
 			// make sure we don't extend past the length of $text
86 87
 			$byte_len = $blocksz;
87
-			if(($pos + $blocksz) > $len)
88
-				$byte_len -= ($pos + $blocksz) - $len;
88
+			if(($pos + $blocksz) > $len) {
89
+							$byte_len -= ($pos + $blocksz) - $len;
90
+			}
89 91
 
90 92
 			// encrypt the register
91 93
 			$this->enc_register = $this->register;
@@ -93,8 +95,9 @@  discard block
 block discarded – undo
93 95
 
94 96
 			// now grab a block of text and a block of from the register, and XOR them
95 97
 			$block = substr($text, $pos, $byte_len);
96
-			for($j = 0; $j < $byte_len; ++$j)
97
-				$block[$j] = $block[$j] ^ $this->enc_register[$j];
98
+			for($j = 0; $j < $byte_len; ++$j) {
99
+							$block[$j] = $block[$j] ^ $this->enc_register[$j];
100
+			}
98 101
 
99 102
 			// replace the plain text block with encrypted text
100 103
 			$text = substr_replace($text, $block, $pos, $byte_len);
@@ -127,8 +130,9 @@  discard block
 block discarded – undo
127 130
 
128 131
 			// make sure we don't extend past the length of $text
129 132
 			$byte_len = $blocksz;
130
-			if(($pos + $byte_len) > $len)
131
-				$byte_len -= ($pos + $byte_len) - $len;
133
+			if(($pos + $byte_len) > $len) {
134
+							$byte_len -= ($pos + $byte_len) - $len;
135
+			}
132 136
 
133 137
 			// encrypt the register
134 138
 			$this->enc_register = $this->register;
@@ -140,8 +144,9 @@  discard block
 block discarded – undo
140 144
 
141 145
 			// now grab a block of text and xor with the register
142 146
 			$block = substr($text, $pos, $byte_len);
143
-			for($j = 0; $j < $byte_len; ++$j)
144
-				$block[$j] = $block[$j] ^ $this->enc_register[$j];
147
+			for($j = 0; $j < $byte_len; ++$j) {
148
+							$block[$j] = $block[$j] ^ $this->enc_register[$j];
149
+			}
145 150
 
146 151
 			// replace the encrypted block with plain text
147 152
 			$text = substr_replace($text, $block, $pos, $byte_len);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/CBC.php 3 patches
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -36,132 +36,132 @@
 block discarded – undo
36 36
  */
37 37
 class Mode_CBC extends Mode
38 38
 {
39
-	/**
40
-	 * Constructor
41
-	 * Sets the cipher object that will be used for encryption
42
-	 *
43
-	 * @param object $cipher one of the phpCrypt encryption cipher objects
44
-	 * @return void
45
-	 */
46
-	function __construct($cipher)
47
-	{
48
-		parent::__construct(PHP_Crypt::MODE_CBC, $cipher);
49
-
50
-		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("CBC mode requires a block cipher", E_USER_WARNING);
53
-	}
54
-
55
-
56
-	/**
57
-	 * Destructor
58
-	 *
59
-	 * @return void
60
-	 */
61
-	public function __destruct()
62
-	{
63
-		parent::__destruct();
64
-	}
65
-
66
-
67
-	/**
68
-	 * Encrypts an the entire string $plain_text using the cipher passed
69
-	 * to the constructor in CBC mode
70
-	 * The steps to encrypt using CBC are as follows
71
-	 * 1) Get a block of plain text data to use in the Cipher
72
-	 * 2) XOR the block with IV (if it's the first round) or the previous
73
-	 *	round's encrypted result
74
-	 * 3) Encrypt the block using the cipher
75
-	 * 4) Save the encrypted block to use in the next round
76
-	 *
77
-	 * @param string $text the string to be encrypted in CBC mode
78
-	 * @return boolean Returns true
79
-	 */
80
-	public function encrypt(&$text)
81
-	{
82
-		$this->pad($text);
83
-		$blocksz = $this->cipher->blockSize();
84
-
85
-		$max = strlen($text) / $blocksz;
86
-		for($i = 0; $i < $max; ++$i)
87
-		{
88
-			// get the current position in $text
89
-			$pos = $i * $blocksz;
90
-
91
-			// grab a block of plain text
92
-			$block = substr($text, $pos, $blocksz);
93
-
94
-			// xor the block with the register
95
-			for($j = 0; $j < $blocksz; ++$j)
96
-				$block[$j] = $block[$j] ^ $this->register[$j];
97
-
98
-			// encrypt the block, and save it back to the register
99
-			$this->cipher->encrypt($block);
100
-			$this->register = $block;
101
-
102
-			// replace the plain text block with the cipher text
103
-			$text = substr_replace($text, $this->register, $pos, $blocksz);
104
-		}
105
-
106
-		return true;
107
-	}
108
-
109
-
110
-	/**
111
-	 * Decrypts an the entire string $plain_text using the cipher passed
112
-	 * to the constructor in CBC mode
113
-	 * The decryption algorithm requires the following steps
114
-	 * 1) Get the first block of encrypted text, save it
115
-	 * 2) Decrypt the block
116
-	 * 3) XOR the decrypted block (if it's the first pass use the IV,
117
-	 *	else use the encrypted block from step 1
118
-	 * 4) the result from the XOR will be a plain text block, save it
119
-	 * 5) assign the encrypted block from step 1 to use in the next round
120
-	 *
121
-	 * @param string $text the string to be decrypted in CBC mode
122
-	 * @return boolean Returns true
123
-	 */
124
-	public function decrypt(&$text)
125
-	{
126
-		$blocksz = $this->cipher->blockSize();
127
-
128
-		$max = strlen($text) / $blocksz;
129
-		for($i = 0; $i < $max; ++$i)
130
-		{
131
-			// get the current position in $text
132
-			$pos = $i * $blocksz;
133
-
134
-			// grab a block of cipher text, and save it for use later
135
-			$block = substr($text, $pos, $blocksz);
136
-			$tmp_block = $block;
137
-
138
-			// decrypt the block of cipher text
139
-			$this->cipher->decrypt($block);
140
-
141
-			// xor the block with the register
142
-			for($j = 0; $j < $blocksz; ++$j)
143
-				$block[$j] = $block[$j] ^ $this->register[$j];
144
-
145
-			// replace the block of cipher text with plain text
146
-			$text = substr_replace($text, $block, $pos, $blocksz);
147
-
148
-			// save the cipher text block to the register
149
-			$this->register = $tmp_block;
150
-		}
151
-
152
-		$this->strip($text);
153
-		return true;
154
-	}
155
-
156
-
157
-	/**
158
-	 * This mode requires an IV
159
-	 *
160
-	 * @return boolean Returns True
161
-	 */
162
-	public function requiresIV()
163
-	{
164
-		return true;
165
-	}
39
+    /**
40
+     * Constructor
41
+     * Sets the cipher object that will be used for encryption
42
+     *
43
+     * @param object $cipher one of the phpCrypt encryption cipher objects
44
+     * @return void
45
+     */
46
+    function __construct($cipher)
47
+    {
48
+        parent::__construct(PHP_Crypt::MODE_CBC, $cipher);
49
+
50
+        // this works with only block Ciphers
51
+        if($cipher->type() != Cipher::BLOCK)
52
+            trigger_error("CBC mode requires a block cipher", E_USER_WARNING);
53
+    }
54
+
55
+
56
+    /**
57
+     * Destructor
58
+     *
59
+     * @return void
60
+     */
61
+    public function __destruct()
62
+    {
63
+        parent::__destruct();
64
+    }
65
+
66
+
67
+    /**
68
+     * Encrypts an the entire string $plain_text using the cipher passed
69
+     * to the constructor in CBC mode
70
+     * The steps to encrypt using CBC are as follows
71
+     * 1) Get a block of plain text data to use in the Cipher
72
+     * 2) XOR the block with IV (if it's the first round) or the previous
73
+     *	round's encrypted result
74
+     * 3) Encrypt the block using the cipher
75
+     * 4) Save the encrypted block to use in the next round
76
+     *
77
+     * @param string $text the string to be encrypted in CBC mode
78
+     * @return boolean Returns true
79
+     */
80
+    public function encrypt(&$text)
81
+    {
82
+        $this->pad($text);
83
+        $blocksz = $this->cipher->blockSize();
84
+
85
+        $max = strlen($text) / $blocksz;
86
+        for($i = 0; $i < $max; ++$i)
87
+        {
88
+            // get the current position in $text
89
+            $pos = $i * $blocksz;
90
+
91
+            // grab a block of plain text
92
+            $block = substr($text, $pos, $blocksz);
93
+
94
+            // xor the block with the register
95
+            for($j = 0; $j < $blocksz; ++$j)
96
+                $block[$j] = $block[$j] ^ $this->register[$j];
97
+
98
+            // encrypt the block, and save it back to the register
99
+            $this->cipher->encrypt($block);
100
+            $this->register = $block;
101
+
102
+            // replace the plain text block with the cipher text
103
+            $text = substr_replace($text, $this->register, $pos, $blocksz);
104
+        }
105
+
106
+        return true;
107
+    }
108
+
109
+
110
+    /**
111
+     * Decrypts an the entire string $plain_text using the cipher passed
112
+     * to the constructor in CBC mode
113
+     * The decryption algorithm requires the following steps
114
+     * 1) Get the first block of encrypted text, save it
115
+     * 2) Decrypt the block
116
+     * 3) XOR the decrypted block (if it's the first pass use the IV,
117
+     *	else use the encrypted block from step 1
118
+     * 4) the result from the XOR will be a plain text block, save it
119
+     * 5) assign the encrypted block from step 1 to use in the next round
120
+     *
121
+     * @param string $text the string to be decrypted in CBC mode
122
+     * @return boolean Returns true
123
+     */
124
+    public function decrypt(&$text)
125
+    {
126
+        $blocksz = $this->cipher->blockSize();
127
+
128
+        $max = strlen($text) / $blocksz;
129
+        for($i = 0; $i < $max; ++$i)
130
+        {
131
+            // get the current position in $text
132
+            $pos = $i * $blocksz;
133
+
134
+            // grab a block of cipher text, and save it for use later
135
+            $block = substr($text, $pos, $blocksz);
136
+            $tmp_block = $block;
137
+
138
+            // decrypt the block of cipher text
139
+            $this->cipher->decrypt($block);
140
+
141
+            // xor the block with the register
142
+            for($j = 0; $j < $blocksz; ++$j)
143
+                $block[$j] = $block[$j] ^ $this->register[$j];
144
+
145
+            // replace the block of cipher text with plain text
146
+            $text = substr_replace($text, $block, $pos, $blocksz);
147
+
148
+            // save the cipher text block to the register
149
+            $this->register = $tmp_block;
150
+        }
151
+
152
+        $this->strip($text);
153
+        return true;
154
+    }
155
+
156
+
157
+    /**
158
+     * This mode requires an IV
159
+     *
160
+     * @return boolean Returns True
161
+     */
162
+    public function requiresIV()
163
+    {
164
+        return true;
165
+    }
166 166
 }
167 167
 ?>
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		parent::__construct(PHP_Crypt::MODE_CBC, $cipher);
49 49
 
50 50
 		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
51
+		if ($cipher->type() != Cipher::BLOCK)
52 52
 			trigger_error("CBC mode requires a block cipher", E_USER_WARNING);
53 53
 	}
54 54
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		$blocksz = $this->cipher->blockSize();
84 84
 
85 85
 		$max = strlen($text) / $blocksz;
86
-		for($i = 0; $i < $max; ++$i)
86
+		for ($i = 0; $i < $max; ++$i)
87 87
 		{
88 88
 			// get the current position in $text
89 89
 			$pos = $i * $blocksz;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			$block = substr($text, $pos, $blocksz);
93 93
 
94 94
 			// xor the block with the register
95
-			for($j = 0; $j < $blocksz; ++$j)
95
+			for ($j = 0; $j < $blocksz; ++$j)
96 96
 				$block[$j] = $block[$j] ^ $this->register[$j];
97 97
 
98 98
 			// encrypt the block, and save it back to the register
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		$blocksz = $this->cipher->blockSize();
127 127
 
128 128
 		$max = strlen($text) / $blocksz;
129
-		for($i = 0; $i < $max; ++$i)
129
+		for ($i = 0; $i < $max; ++$i)
130 130
 		{
131 131
 			// get the current position in $text
132 132
 			$pos = $i * $blocksz;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 			$this->cipher->decrypt($block);
140 140
 
141 141
 			// xor the block with the register
142
-			for($j = 0; $j < $blocksz; ++$j)
142
+			for ($j = 0; $j < $blocksz; ++$j)
143 143
 				$block[$j] = $block[$j] ^ $this->register[$j];
144 144
 
145 145
 			// replace the block of cipher text with plain text
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 		parent::__construct(PHP_Crypt::MODE_CBC, $cipher);
49 49
 
50 50
 		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("CBC mode requires a block cipher", E_USER_WARNING);
51
+		if($cipher->type() != Cipher::BLOCK) {
52
+					trigger_error("CBC mode requires a block cipher", E_USER_WARNING);
53
+		}
53 54
 	}
54 55
 
55 56
 
@@ -92,8 +93,9 @@  discard block
 block discarded – undo
92 93
 			$block = substr($text, $pos, $blocksz);
93 94
 
94 95
 			// xor the block with the register
95
-			for($j = 0; $j < $blocksz; ++$j)
96
-				$block[$j] = $block[$j] ^ $this->register[$j];
96
+			for($j = 0; $j < $blocksz; ++$j) {
97
+							$block[$j] = $block[$j] ^ $this->register[$j];
98
+			}
97 99
 
98 100
 			// encrypt the block, and save it back to the register
99 101
 			$this->cipher->encrypt($block);
@@ -139,8 +141,9 @@  discard block
 block discarded – undo
139 141
 			$this->cipher->decrypt($block);
140 142
 
141 143
 			// xor the block with the register
142
-			for($j = 0; $j < $blocksz; ++$j)
143
-				$block[$j] = $block[$j] ^ $this->register[$j];
144
+			for($j = 0; $j < $blocksz; ++$j) {
145
+							$block[$j] = $block[$j] ^ $this->register[$j];
146
+			}
144 147
 
145 148
 			// replace the block of cipher text with plain text
146 149
 			$text = substr_replace($text, $block, $pos, $blocksz);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/Stream.php 3 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -38,32 +38,32 @@
 block discarded – undo
38 38
  */
39 39
 class Mode_Stream extends Mode_Raw
40 40
 {
41
-	/**
42
-	 * Constructor
43
-	 * Sets the cipher object that will be used for encryption
44
-	 *
45
-	 * @param object $cipher one of the phpCrypt encryption cipher objects
46
-	 * @return void
47
-	 */
48
-	public function __construct($cipher)
49
-	{
50
-		// call the secondary 'constructor' from the parent
51
-		parent::__construct1(PHP_Crypt::MODE_STREAM, $cipher);
41
+    /**
42
+     * Constructor
43
+     * Sets the cipher object that will be used for encryption
44
+     *
45
+     * @param object $cipher one of the phpCrypt encryption cipher objects
46
+     * @return void
47
+     */
48
+    public function __construct($cipher)
49
+    {
50
+        // call the secondary 'constructor' from the parent
51
+        parent::__construct1(PHP_Crypt::MODE_STREAM, $cipher);
52 52
 
53
-		// this works with only stream Ciphers
54
-		if($cipher->type() != Cipher::STREAM)
55
-			trigger_error("Stream mode requires a stream cipher", E_USER_WARNING);
56
-	}
53
+        // this works with only stream Ciphers
54
+        if($cipher->type() != Cipher::STREAM)
55
+            trigger_error("Stream mode requires a stream cipher", E_USER_WARNING);
56
+    }
57 57
 
58 58
 
59
-	/**
60
-	 * Destructor
61
-	 *
62
-	 * @return void
63
-	 */
64
-	public function __destruct()
65
-	{
66
-		parent::__destruct();
67
-	}
59
+    /**
60
+     * Destructor
61
+     *
62
+     * @return void
63
+     */
64
+    public function __destruct()
65
+    {
66
+        parent::__destruct();
67
+    }
68 68
 }
69 69
 ?>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 		parent::__construct1(PHP_Crypt::MODE_STREAM, $cipher);
52 52
 
53 53
 		// this works with only stream Ciphers
54
-		if($cipher->type() != Cipher::STREAM)
54
+		if ($cipher->type() != Cipher::STREAM)
55 55
 			trigger_error("Stream mode requires a stream cipher", E_USER_WARNING);
56 56
 	}
57 57
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@
 block discarded – undo
51 51
 		parent::__construct1(PHP_Crypt::MODE_STREAM, $cipher);
52 52
 
53 53
 		// this works with only stream Ciphers
54
-		if($cipher->type() != Cipher::STREAM)
55
-			trigger_error("Stream mode requires a stream cipher", E_USER_WARNING);
54
+		if($cipher->type() != Cipher::STREAM) {
55
+					trigger_error("Stream mode requires a stream cipher", E_USER_WARNING);
56
+		}
56 57
 	}
57 58
 
58 59
 
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/OFB.php 3 patches
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -36,91 +36,91 @@
 block discarded – undo
36 36
  */
37 37
 class Mode_OFB extends Mode
38 38
 {
39
-	/**
40
-	 * Constructor
41
-	 * Sets the cipher object that will be used for encryption
42
-	 *
43
-	 * @param object $cipher one of the phpCrypt encryption cipher objects
44
-	 * @return void
45
-	 */
46
-	public function __construct($cipher)
47
-	{
48
-		parent::__construct(PHP_Crypt::MODE_OFB, $cipher);
49
-
50
-		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("OFB mode requires a block cipher", E_USER_WARNING);
53
-	}
54
-
55
-
56
-	/**
57
-	 * Destructor
58
-	 *
59
-	 * @return void
60
-	 */
61
-	public function __destruct()
62
-	{
63
-		parent::__destruct();
64
-	}
65
-
66
-
67
-	/**
68
-	 * Encrypts an the entire string $plain_text using the cipher passed
69
-	 *
70
-	 * @param string $text the string to be encrypted
71
-	 * @return boolean Returns true
72
-	 */
73
-	public function encrypt(&$text)
74
-	{
75
-		$max = strlen($text);
76
-		for($i = 0; $i < $max; ++$i)
77
-		{
78
-			$this->enc_register = $this->register;
79
-			$this->cipher->encrypt($this->enc_register);
80
-			$text[$i] = $text[$i] ^ $this->enc_register[0];
81
-
82
-			// shift the register left
83
-			$this->register = substr($this->register, 1);
84
-			$this->register .= $this->enc_register[0];
85
-		}
86
-
87
-		return true;
88
-	}
89
-
90
-
91
-	/**
92
-	 * Decrypts an the entire string $plain_text using the cipher passed
93
-	 *
94
-	 * @param string $text the string to be decrypted
95
-	 * @return boolean Returns true
96
-	 */
97
-	public function decrypt(&$text)
98
-	{
99
-		$max = strlen($text);
100
-		for($i = 0; $i < $max; ++$i)
101
-		{
102
-			$this->enc_register = $this->register;
103
-			$this->cipher->encrypt($this->enc_register);
104
-
105
-			// shift the register left
106
-			$this->register = substr($this->register, 1);
107
-			$this->register .= $this->enc_register[0];
108
-
109
-			$text[$i] = $text[$i] ^ $this->enc_register[0];
110
-		}
111
-
112
-		return true;
113
-	}
114
-
115
-
116
-	/**
117
-	 * This mode requires an IV
118
-	 *
119
-	 * @return boolean true
120
-	 */
121
-	public function requiresIV()
122
-	{
123
-		return true;
124
-	}
39
+    /**
40
+     * Constructor
41
+     * Sets the cipher object that will be used for encryption
42
+     *
43
+     * @param object $cipher one of the phpCrypt encryption cipher objects
44
+     * @return void
45
+     */
46
+    public function __construct($cipher)
47
+    {
48
+        parent::__construct(PHP_Crypt::MODE_OFB, $cipher);
49
+
50
+        // this works with only block Ciphers
51
+        if($cipher->type() != Cipher::BLOCK)
52
+            trigger_error("OFB mode requires a block cipher", E_USER_WARNING);
53
+    }
54
+
55
+
56
+    /**
57
+     * Destructor
58
+     *
59
+     * @return void
60
+     */
61
+    public function __destruct()
62
+    {
63
+        parent::__destruct();
64
+    }
65
+
66
+
67
+    /**
68
+     * Encrypts an the entire string $plain_text using the cipher passed
69
+     *
70
+     * @param string $text the string to be encrypted
71
+     * @return boolean Returns true
72
+     */
73
+    public function encrypt(&$text)
74
+    {
75
+        $max = strlen($text);
76
+        for($i = 0; $i < $max; ++$i)
77
+        {
78
+            $this->enc_register = $this->register;
79
+            $this->cipher->encrypt($this->enc_register);
80
+            $text[$i] = $text[$i] ^ $this->enc_register[0];
81
+
82
+            // shift the register left
83
+            $this->register = substr($this->register, 1);
84
+            $this->register .= $this->enc_register[0];
85
+        }
86
+
87
+        return true;
88
+    }
89
+
90
+
91
+    /**
92
+     * Decrypts an the entire string $plain_text using the cipher passed
93
+     *
94
+     * @param string $text the string to be decrypted
95
+     * @return boolean Returns true
96
+     */
97
+    public function decrypt(&$text)
98
+    {
99
+        $max = strlen($text);
100
+        for($i = 0; $i < $max; ++$i)
101
+        {
102
+            $this->enc_register = $this->register;
103
+            $this->cipher->encrypt($this->enc_register);
104
+
105
+            // shift the register left
106
+            $this->register = substr($this->register, 1);
107
+            $this->register .= $this->enc_register[0];
108
+
109
+            $text[$i] = $text[$i] ^ $this->enc_register[0];
110
+        }
111
+
112
+        return true;
113
+    }
114
+
115
+
116
+    /**
117
+     * This mode requires an IV
118
+     *
119
+     * @return boolean true
120
+     */
121
+    public function requiresIV()
122
+    {
123
+        return true;
124
+    }
125 125
 }
126 126
 ?>
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		parent::__construct(PHP_Crypt::MODE_OFB, $cipher);
49 49
 
50 50
 		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
51
+		if ($cipher->type() != Cipher::BLOCK)
52 52
 			trigger_error("OFB mode requires a block cipher", E_USER_WARNING);
53 53
 	}
54 54
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	public function encrypt(&$text)
74 74
 	{
75 75
 		$max = strlen($text);
76
-		for($i = 0; $i < $max; ++$i)
76
+		for ($i = 0; $i < $max; ++$i)
77 77
 		{
78 78
 			$this->enc_register = $this->register;
79 79
 			$this->cipher->encrypt($this->enc_register);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	public function decrypt(&$text)
98 98
 	{
99 99
 		$max = strlen($text);
100
-		for($i = 0; $i < $max; ++$i)
100
+		for ($i = 0; $i < $max; ++$i)
101 101
 		{
102 102
 			$this->enc_register = $this->register;
103 103
 			$this->cipher->encrypt($this->enc_register);
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@
 block discarded – undo
48 48
 		parent::__construct(PHP_Crypt::MODE_OFB, $cipher);
49 49
 
50 50
 		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("OFB mode requires a block cipher", E_USER_WARNING);
51
+		if($cipher->type() != Cipher::BLOCK) {
52
+					trigger_error("OFB mode requires a block cipher", E_USER_WARNING);
53
+		}
53 54
 	}
54 55
 
55 56
 
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/NCFB.php 3 patches
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -37,135 +37,135 @@
 block discarded – undo
37 37
  */
38 38
 class Mode_NCFB extends Mode
39 39
 {
40
-	/**
41
-	 * The constructor, Sets the cipher object that will be used for encryption
42
-	 *
43
-	 * @param object $cipher one of the phpCrypt encryption cipher objects
44
-	 * @return void
45
-	 */
46
-	public function __construct($cipher)
47
-	{
48
-		parent::__construct(PHP_Crypt::MODE_NCFB, $cipher);
49
-
50
-		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("NCFB mode requires a block cipher", E_USER_WARNING);
53
-	}
54
-
55
-
56
-	/**
57
-	 * Destructor
58
-	 *
59
-	 * @return void
60
-	 */
61
-	public function __destruct()
62
-	{
63
-		parent::__destruct();
64
-	}
65
-
66
-
67
-	/**
68
-	 * Encrypts an the entire string $plain_text using the cipher passed
69
-	 *
70
-	 * @param string $text the string to be encrypted
71
-	 * @return boolean True
72
-	 */
73
-	public function encrypt(&$text)
74
-	{
75
-		$blocksz = $this->cipher->blockSize();
76
-
77
-		// first we need to pad the string so its the correct length for the cipher
78
-		$len = strlen($text);
79
-
80
-		// if $len is less than blockSize() this will still work, as even
81
-		// a fraction is greater than 0
82
-		$max = $len / $blocksz;
83
-		for($i = 0; $i < $max; ++$i)
84
-		{
85
-			// current position in the text
86
-			$pos = $i * $blocksz;
87
-
88
-			// make sure we don't extend past the length of $text
89
-			$byte_len = $blocksz;
90
-
91
-			if(($pos + $byte_len) > $len)
92
-				$byte_len -= ($pos + $byte_len) - $len;
93
-
94
-			// encrypt the register
95
-			$this->enc_register = $this->register;
96
-			$this->cipher->encrypt($this->enc_register);
97
-
98
-			// encrypt the block by xoring it with the encrypted register
99
-			$block = substr($text, $pos, $byte_len);
100
-
101
-			// xor the block
102
-			for($j = 0; $j < $byte_len; ++$j)
103
-				$block[$j] = $block[$j] ^ $this->enc_register[$j];
104
-
105
-			// replace the plain text block with the encrypted block
106
-			$text = substr_replace($text, $block, $pos, $byte_len);
107
-
108
-			// shift the register left n-bytes, append n-bytes of encrypted register
109
-			$this->register = substr($this->register, $blocksz);
110
-			$this->register .= $block;
111
-		}
112
-
113
-		return true;
114
-	}
115
-
116
-
117
-	/**
118
-	 * Decrypts an the entire string $plain_text using the cipher passed
119
-	 *
120
-	 * @param string $text the string to be decrypted
121
-	 * @return bool Returns True
122
-	 */
123
-	public function decrypt(&$text)
124
-	{
125
-		$blocksz = $this->cipher->blockSize();
126
-		$len = strlen($text);
127
-
128
-		// if $len is less than blockSize() this will still work, as even
129
-		// a fraction is greater than 0
130
-		$max = $len / $blocksz;
131
-		for($i = 0; $i < $max; ++$i)
132
-		{
133
-			// get the current position in text
134
-			$pos = $i * $blocksz;
135
-
136
-			// make sure we don't extend past the length of $text
137
-			$byte_len = $blocksz;
138
-			if(($pos + $byte_len) > $len)
139
-				$byte_len -= ($pos + $byte_len) - $len;
140
-
141
-			// encrypt the register
142
-			$this->enc_register = $this->register;
143
-			$this->cipher->encrypt($this->enc_register);
144
-
145
-			// shift the register left, push the encrypted byte onto the end
146
-			$block = substr($text, $pos, $byte_len);
147
-			$this->register = $block;
148
-
149
-			// xor the block
150
-			for($j = 0; $j < $byte_len; ++$j)
151
-				$block[$j] = $block[$j] ^ $this->enc_register[$j];
152
-
153
-			// replace the encrypted block with the plain text block
154
-			$text = substr_replace($text, $block, $pos, $byte_len);
155
-		}
156
-
157
-		return true;
158
-	}
159
-
160
-
161
-	/**
162
-	 * This mode requires an IV
163
-	 *
164
-	 * @return boolean true
165
-	 */
166
-	public function requiresIV()
167
-	{
168
-		return true;
169
-	}
40
+    /**
41
+     * The constructor, Sets the cipher object that will be used for encryption
42
+     *
43
+     * @param object $cipher one of the phpCrypt encryption cipher objects
44
+     * @return void
45
+     */
46
+    public function __construct($cipher)
47
+    {
48
+        parent::__construct(PHP_Crypt::MODE_NCFB, $cipher);
49
+
50
+        // this works with only block Ciphers
51
+        if($cipher->type() != Cipher::BLOCK)
52
+            trigger_error("NCFB mode requires a block cipher", E_USER_WARNING);
53
+    }
54
+
55
+
56
+    /**
57
+     * Destructor
58
+     *
59
+     * @return void
60
+     */
61
+    public function __destruct()
62
+    {
63
+        parent::__destruct();
64
+    }
65
+
66
+
67
+    /**
68
+     * Encrypts an the entire string $plain_text using the cipher passed
69
+     *
70
+     * @param string $text the string to be encrypted
71
+     * @return boolean True
72
+     */
73
+    public function encrypt(&$text)
74
+    {
75
+        $blocksz = $this->cipher->blockSize();
76
+
77
+        // first we need to pad the string so its the correct length for the cipher
78
+        $len = strlen($text);
79
+
80
+        // if $len is less than blockSize() this will still work, as even
81
+        // a fraction is greater than 0
82
+        $max = $len / $blocksz;
83
+        for($i = 0; $i < $max; ++$i)
84
+        {
85
+            // current position in the text
86
+            $pos = $i * $blocksz;
87
+
88
+            // make sure we don't extend past the length of $text
89
+            $byte_len = $blocksz;
90
+
91
+            if(($pos + $byte_len) > $len)
92
+                $byte_len -= ($pos + $byte_len) - $len;
93
+
94
+            // encrypt the register
95
+            $this->enc_register = $this->register;
96
+            $this->cipher->encrypt($this->enc_register);
97
+
98
+            // encrypt the block by xoring it with the encrypted register
99
+            $block = substr($text, $pos, $byte_len);
100
+
101
+            // xor the block
102
+            for($j = 0; $j < $byte_len; ++$j)
103
+                $block[$j] = $block[$j] ^ $this->enc_register[$j];
104
+
105
+            // replace the plain text block with the encrypted block
106
+            $text = substr_replace($text, $block, $pos, $byte_len);
107
+
108
+            // shift the register left n-bytes, append n-bytes of encrypted register
109
+            $this->register = substr($this->register, $blocksz);
110
+            $this->register .= $block;
111
+        }
112
+
113
+        return true;
114
+    }
115
+
116
+
117
+    /**
118
+     * Decrypts an the entire string $plain_text using the cipher passed
119
+     *
120
+     * @param string $text the string to be decrypted
121
+     * @return bool Returns True
122
+     */
123
+    public function decrypt(&$text)
124
+    {
125
+        $blocksz = $this->cipher->blockSize();
126
+        $len = strlen($text);
127
+
128
+        // if $len is less than blockSize() this will still work, as even
129
+        // a fraction is greater than 0
130
+        $max = $len / $blocksz;
131
+        for($i = 0; $i < $max; ++$i)
132
+        {
133
+            // get the current position in text
134
+            $pos = $i * $blocksz;
135
+
136
+            // make sure we don't extend past the length of $text
137
+            $byte_len = $blocksz;
138
+            if(($pos + $byte_len) > $len)
139
+                $byte_len -= ($pos + $byte_len) - $len;
140
+
141
+            // encrypt the register
142
+            $this->enc_register = $this->register;
143
+            $this->cipher->encrypt($this->enc_register);
144
+
145
+            // shift the register left, push the encrypted byte onto the end
146
+            $block = substr($text, $pos, $byte_len);
147
+            $this->register = $block;
148
+
149
+            // xor the block
150
+            for($j = 0; $j < $byte_len; ++$j)
151
+                $block[$j] = $block[$j] ^ $this->enc_register[$j];
152
+
153
+            // replace the encrypted block with the plain text block
154
+            $text = substr_replace($text, $block, $pos, $byte_len);
155
+        }
156
+
157
+        return true;
158
+    }
159
+
160
+
161
+    /**
162
+     * This mode requires an IV
163
+     *
164
+     * @return boolean true
165
+     */
166
+    public function requiresIV()
167
+    {
168
+        return true;
169
+    }
170 170
 }
171 171
 ?>
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		parent::__construct(PHP_Crypt::MODE_NCFB, $cipher);
49 49
 
50 50
 		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
51
+		if ($cipher->type() != Cipher::BLOCK)
52 52
 			trigger_error("NCFB mode requires a block cipher", E_USER_WARNING);
53 53
 	}
54 54
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		// if $len is less than blockSize() this will still work, as even
81 81
 		// a fraction is greater than 0
82 82
 		$max = $len / $blocksz;
83
-		for($i = 0; $i < $max; ++$i)
83
+		for ($i = 0; $i < $max; ++$i)
84 84
 		{
85 85
 			// current position in the text
86 86
 			$pos = $i * $blocksz;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 			// make sure we don't extend past the length of $text
89 89
 			$byte_len = $blocksz;
90 90
 
91
-			if(($pos + $byte_len) > $len)
91
+			if (($pos + $byte_len) > $len)
92 92
 				$byte_len -= ($pos + $byte_len) - $len;
93 93
 
94 94
 			// encrypt the register
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 			$block = substr($text, $pos, $byte_len);
100 100
 
101 101
 			// xor the block
102
-			for($j = 0; $j < $byte_len; ++$j)
102
+			for ($j = 0; $j < $byte_len; ++$j)
103 103
 				$block[$j] = $block[$j] ^ $this->enc_register[$j];
104 104
 
105 105
 			// replace the plain text block with the encrypted block
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 		// if $len is less than blockSize() this will still work, as even
129 129
 		// a fraction is greater than 0
130 130
 		$max = $len / $blocksz;
131
-		for($i = 0; $i < $max; ++$i)
131
+		for ($i = 0; $i < $max; ++$i)
132 132
 		{
133 133
 			// get the current position in text
134 134
 			$pos = $i * $blocksz;
135 135
 
136 136
 			// make sure we don't extend past the length of $text
137 137
 			$byte_len = $blocksz;
138
-			if(($pos + $byte_len) > $len)
138
+			if (($pos + $byte_len) > $len)
139 139
 				$byte_len -= ($pos + $byte_len) - $len;
140 140
 
141 141
 			// encrypt the register
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			$this->register = $block;
148 148
 
149 149
 			// xor the block
150
-			for($j = 0; $j < $byte_len; ++$j)
150
+			for ($j = 0; $j < $byte_len; ++$j)
151 151
 				$block[$j] = $block[$j] ^ $this->enc_register[$j];
152 152
 
153 153
 			// replace the encrypted block with the plain text block
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 		parent::__construct(PHP_Crypt::MODE_NCFB, $cipher);
49 49
 
50 50
 		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("NCFB mode requires a block cipher", E_USER_WARNING);
51
+		if($cipher->type() != Cipher::BLOCK) {
52
+					trigger_error("NCFB mode requires a block cipher", E_USER_WARNING);
53
+		}
53 54
 	}
54 55
 
55 56
 
@@ -88,8 +89,9 @@  discard block
 block discarded – undo
88 89
 			// make sure we don't extend past the length of $text
89 90
 			$byte_len = $blocksz;
90 91
 
91
-			if(($pos + $byte_len) > $len)
92
-				$byte_len -= ($pos + $byte_len) - $len;
92
+			if(($pos + $byte_len) > $len) {
93
+							$byte_len -= ($pos + $byte_len) - $len;
94
+			}
93 95
 
94 96
 			// encrypt the register
95 97
 			$this->enc_register = $this->register;
@@ -99,8 +101,9 @@  discard block
 block discarded – undo
99 101
 			$block = substr($text, $pos, $byte_len);
100 102
 
101 103
 			// xor the block
102
-			for($j = 0; $j < $byte_len; ++$j)
103
-				$block[$j] = $block[$j] ^ $this->enc_register[$j];
104
+			for($j = 0; $j < $byte_len; ++$j) {
105
+							$block[$j] = $block[$j] ^ $this->enc_register[$j];
106
+			}
104 107
 
105 108
 			// replace the plain text block with the encrypted block
106 109
 			$text = substr_replace($text, $block, $pos, $byte_len);
@@ -135,8 +138,9 @@  discard block
 block discarded – undo
135 138
 
136 139
 			// make sure we don't extend past the length of $text
137 140
 			$byte_len = $blocksz;
138
-			if(($pos + $byte_len) > $len)
139
-				$byte_len -= ($pos + $byte_len) - $len;
141
+			if(($pos + $byte_len) > $len) {
142
+							$byte_len -= ($pos + $byte_len) - $len;
143
+			}
140 144
 
141 145
 			// encrypt the register
142 146
 			$this->enc_register = $this->register;
@@ -147,8 +151,9 @@  discard block
 block discarded – undo
147 151
 			$this->register = $block;
148 152
 
149 153
 			// xor the block
150
-			for($j = 0; $j < $byte_len; ++$j)
151
-				$block[$j] = $block[$j] ^ $this->enc_register[$j];
154
+			for($j = 0; $j < $byte_len; ++$j) {
155
+							$block[$j] = $block[$j] ^ $this->enc_register[$j];
156
+			}
152 157
 
153 158
 			// replace the encrypted block with the plain text block
154 159
 			$text = substr_replace($text, $block, $pos, $byte_len);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/PCBC.php 3 patches
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -36,124 +36,124 @@
 block discarded – undo
36 36
  */
37 37
 class Mode_PCBC extends Mode
38 38
 {
39
-	/**
40
-	 * Constructor
41
-	 * Sets the cipher object that will be used for encryption
42
-	 *
43
-	 * @param object $cipher one of the phpCrypt encryption cipher objects
44
-	 * @return void
45
-	 */
46
-	function __construct($cipher)
47
-	{
48
-		parent::__construct(PHP_Crypt::MODE_PCBC, $cipher);
49
-
50
-		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("PCBC mode requires a block cipher", E_USER_WARNING);
53
-	}
54
-
55
-
56
-	/**
57
-	 * Destructor
58
-	 *
59
-	 * @return void
60
-	 */
61
-	public function __destruct()
62
-	{
63
-		parent::__destruct();
64
-	}
65
-
66
-
67
-	/**
68
-	 * Encrypts an the entire string $plain_text using the cipher
69
-	 *
70
-	 * @param string $text the string to be encrypted
71
-	 * @return boolean Returns true
72
-	 */
73
-	public function encrypt(&$text)
74
-	{
75
-		$this->pad($text);
76
-		$blocksz = $this->cipher->blockSize();
77
-
78
-		$max = strlen($text) / $blocksz;
79
-		for($i = 0; $i < $max; ++$i)
80
-		{
81
-			// current position in the text
82
-			$pos = $i * $blocksz;
83
-
84
-			// get a block of plain text, and make a copy
85
-			$block = substr($text, $pos, $blocksz);
86
-			$plain_block = $block;
87
-
88
-			// xor the register with plain text
89
-			for($j = 0; $j < $blocksz; ++$j)
90
-				$block[$j] = $this->register[$j] ^ $block[$j];
91
-
92
-			// encrypt the block creating the cipher text
93
-			$this->cipher->encrypt($block);
94
-
95
-			// xor the encrypted block with the plain text block to create
96
-			// the register in the next round
97
-			for($j = 0; $j < $blocksz; ++$j)
98
-				$this->register[$j] = $block[$j] ^ $plain_block[$j];
99
-
100
-			// copy the encrypted block back to $text
101
-			$text = substr_replace($text, $block, $pos, $blocksz);
102
-		}
103
-
104
-		return true;
105
-	}
106
-
107
-
108
-	/**
109
-	 * Decrypts an the entire string $plain_text using the cipher
110
-	 *
111
-	 * @param string $text the string to be decrypted
112
-	 * @return boolean Returns true
113
-	 */
114
-	public function decrypt(&$text)
115
-	{
116
-		$blocksz = $this->cipher->blockSize();
117
-
118
-		$max = strlen($text) / $blocksz;
119
-		for($i = 0; $i < $max; ++$i)
120
-		{
121
-			// current position in the text
122
-			$pos = $i * $blocksz;
123
-
124
-			// get a block of encrypted text, and make a copy
125
-			$block = substr($text, $pos, $blocksz);
126
-			$enc_block = $block;
127
-
128
-			// decrypt the block
129
-			$this->cipher->decrypt($block);
130
-
131
-			// xor the decrypted block with the register, to create
132
-			// the plain text block
133
-			for($j = 0; $j < $blocksz; ++$j)
134
-				$block[$j] = $this->register[$j] ^ $block[$j];
135
-
136
-			// now xor the $enc_block with the unencrypted $block
137
-			for($j = 0; $j < $blocksz; ++$j)
138
-				$this->register[$j] = $block[$j] ^ $enc_block[$j];
139
-
140
-			// copy the plain text block back to $text
141
-			$text = substr_replace($text, $block, $pos, $blocksz);
142
-		}
143
-
144
-		$this->strip($text);
145
-		return true;
146
-	}
147
-
148
-
149
-	/**
150
-	 * This mode requires an IV
151
-	 *
152
-	 * @return boolean Returns true
153
-	 */
154
-	public function requiresIV()
155
-	{
156
-		return true;
157
-	}
39
+    /**
40
+     * Constructor
41
+     * Sets the cipher object that will be used for encryption
42
+     *
43
+     * @param object $cipher one of the phpCrypt encryption cipher objects
44
+     * @return void
45
+     */
46
+    function __construct($cipher)
47
+    {
48
+        parent::__construct(PHP_Crypt::MODE_PCBC, $cipher);
49
+
50
+        // this works with only block Ciphers
51
+        if($cipher->type() != Cipher::BLOCK)
52
+            trigger_error("PCBC mode requires a block cipher", E_USER_WARNING);
53
+    }
54
+
55
+
56
+    /**
57
+     * Destructor
58
+     *
59
+     * @return void
60
+     */
61
+    public function __destruct()
62
+    {
63
+        parent::__destruct();
64
+    }
65
+
66
+
67
+    /**
68
+     * Encrypts an the entire string $plain_text using the cipher
69
+     *
70
+     * @param string $text the string to be encrypted
71
+     * @return boolean Returns true
72
+     */
73
+    public function encrypt(&$text)
74
+    {
75
+        $this->pad($text);
76
+        $blocksz = $this->cipher->blockSize();
77
+
78
+        $max = strlen($text) / $blocksz;
79
+        for($i = 0; $i < $max; ++$i)
80
+        {
81
+            // current position in the text
82
+            $pos = $i * $blocksz;
83
+
84
+            // get a block of plain text, and make a copy
85
+            $block = substr($text, $pos, $blocksz);
86
+            $plain_block = $block;
87
+
88
+            // xor the register with plain text
89
+            for($j = 0; $j < $blocksz; ++$j)
90
+                $block[$j] = $this->register[$j] ^ $block[$j];
91
+
92
+            // encrypt the block creating the cipher text
93
+            $this->cipher->encrypt($block);
94
+
95
+            // xor the encrypted block with the plain text block to create
96
+            // the register in the next round
97
+            for($j = 0; $j < $blocksz; ++$j)
98
+                $this->register[$j] = $block[$j] ^ $plain_block[$j];
99
+
100
+            // copy the encrypted block back to $text
101
+            $text = substr_replace($text, $block, $pos, $blocksz);
102
+        }
103
+
104
+        return true;
105
+    }
106
+
107
+
108
+    /**
109
+     * Decrypts an the entire string $plain_text using the cipher
110
+     *
111
+     * @param string $text the string to be decrypted
112
+     * @return boolean Returns true
113
+     */
114
+    public function decrypt(&$text)
115
+    {
116
+        $blocksz = $this->cipher->blockSize();
117
+
118
+        $max = strlen($text) / $blocksz;
119
+        for($i = 0; $i < $max; ++$i)
120
+        {
121
+            // current position in the text
122
+            $pos = $i * $blocksz;
123
+
124
+            // get a block of encrypted text, and make a copy
125
+            $block = substr($text, $pos, $blocksz);
126
+            $enc_block = $block;
127
+
128
+            // decrypt the block
129
+            $this->cipher->decrypt($block);
130
+
131
+            // xor the decrypted block with the register, to create
132
+            // the plain text block
133
+            for($j = 0; $j < $blocksz; ++$j)
134
+                $block[$j] = $this->register[$j] ^ $block[$j];
135
+
136
+            // now xor the $enc_block with the unencrypted $block
137
+            for($j = 0; $j < $blocksz; ++$j)
138
+                $this->register[$j] = $block[$j] ^ $enc_block[$j];
139
+
140
+            // copy the plain text block back to $text
141
+            $text = substr_replace($text, $block, $pos, $blocksz);
142
+        }
143
+
144
+        $this->strip($text);
145
+        return true;
146
+    }
147
+
148
+
149
+    /**
150
+     * This mode requires an IV
151
+     *
152
+     * @return boolean Returns true
153
+     */
154
+    public function requiresIV()
155
+    {
156
+        return true;
157
+    }
158 158
 }
159 159
 ?>
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		parent::__construct(PHP_Crypt::MODE_PCBC, $cipher);
49 49
 
50 50
 		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
51
+		if ($cipher->type() != Cipher::BLOCK)
52 52
 			trigger_error("PCBC mode requires a block cipher", E_USER_WARNING);
53 53
 	}
54 54
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		$blocksz = $this->cipher->blockSize();
77 77
 
78 78
 		$max = strlen($text) / $blocksz;
79
-		for($i = 0; $i < $max; ++$i)
79
+		for ($i = 0; $i < $max; ++$i)
80 80
 		{
81 81
 			// current position in the text
82 82
 			$pos = $i * $blocksz;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			$plain_block = $block;
87 87
 
88 88
 			// xor the register with plain text
89
-			for($j = 0; $j < $blocksz; ++$j)
89
+			for ($j = 0; $j < $blocksz; ++$j)
90 90
 				$block[$j] = $this->register[$j] ^ $block[$j];
91 91
 
92 92
 			// encrypt the block creating the cipher text
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
 			// xor the encrypted block with the plain text block to create
96 96
 			// the register in the next round
97
-			for($j = 0; $j < $blocksz; ++$j)
97
+			for ($j = 0; $j < $blocksz; ++$j)
98 98
 				$this->register[$j] = $block[$j] ^ $plain_block[$j];
99 99
 
100 100
 			// copy the encrypted block back to $text
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		$blocksz = $this->cipher->blockSize();
117 117
 
118 118
 		$max = strlen($text) / $blocksz;
119
-		for($i = 0; $i < $max; ++$i)
119
+		for ($i = 0; $i < $max; ++$i)
120 120
 		{
121 121
 			// current position in the text
122 122
 			$pos = $i * $blocksz;
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 
131 131
 			// xor the decrypted block with the register, to create
132 132
 			// the plain text block
133
-			for($j = 0; $j < $blocksz; ++$j)
133
+			for ($j = 0; $j < $blocksz; ++$j)
134 134
 				$block[$j] = $this->register[$j] ^ $block[$j];
135 135
 
136 136
 			// now xor the $enc_block with the unencrypted $block
137
-			for($j = 0; $j < $blocksz; ++$j)
137
+			for ($j = 0; $j < $blocksz; ++$j)
138 138
 				$this->register[$j] = $block[$j] ^ $enc_block[$j];
139 139
 
140 140
 			// copy the plain text block back to $text
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 		parent::__construct(PHP_Crypt::MODE_PCBC, $cipher);
49 49
 
50 50
 		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("PCBC mode requires a block cipher", E_USER_WARNING);
51
+		if($cipher->type() != Cipher::BLOCK) {
52
+					trigger_error("PCBC mode requires a block cipher", E_USER_WARNING);
53
+		}
53 54
 	}
54 55
 
55 56
 
@@ -86,16 +87,18 @@  discard block
 block discarded – undo
86 87
 			$plain_block = $block;
87 88
 
88 89
 			// xor the register with plain text
89
-			for($j = 0; $j < $blocksz; ++$j)
90
-				$block[$j] = $this->register[$j] ^ $block[$j];
90
+			for($j = 0; $j < $blocksz; ++$j) {
91
+							$block[$j] = $this->register[$j] ^ $block[$j];
92
+			}
91 93
 
92 94
 			// encrypt the block creating the cipher text
93 95
 			$this->cipher->encrypt($block);
94 96
 
95 97
 			// xor the encrypted block with the plain text block to create
96 98
 			// the register in the next round
97
-			for($j = 0; $j < $blocksz; ++$j)
98
-				$this->register[$j] = $block[$j] ^ $plain_block[$j];
99
+			for($j = 0; $j < $blocksz; ++$j) {
100
+							$this->register[$j] = $block[$j] ^ $plain_block[$j];
101
+			}
99 102
 
100 103
 			// copy the encrypted block back to $text
101 104
 			$text = substr_replace($text, $block, $pos, $blocksz);
@@ -130,12 +133,14 @@  discard block
 block discarded – undo
130 133
 
131 134
 			// xor the decrypted block with the register, to create
132 135
 			// the plain text block
133
-			for($j = 0; $j < $blocksz; ++$j)
134
-				$block[$j] = $this->register[$j] ^ $block[$j];
136
+			for($j = 0; $j < $blocksz; ++$j) {
137
+							$block[$j] = $this->register[$j] ^ $block[$j];
138
+			}
135 139
 
136 140
 			// now xor the $enc_block with the unencrypted $block
137
-			for($j = 0; $j < $blocksz; ++$j)
138
-				$this->register[$j] = $block[$j] ^ $enc_block[$j];
141
+			for($j = 0; $j < $blocksz; ++$j) {
142
+							$this->register[$j] = $block[$j] ^ $enc_block[$j];
143
+			}
139 144
 
140 145
 			// copy the plain text block back to $text
141 146
 			$text = substr_replace($text, $block, $pos, $blocksz);
Please login to merge, or discard this patch.
includes/libraries/phpcrypt/modes/CFB.php 3 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -36,95 +36,95 @@
 block discarded – undo
36 36
  */
37 37
 class Mode_CFB extends Mode
38 38
 {
39
-	/**
40
-	 * Constructor
41
-	 * Sets the cipher object that will be used for encryption
42
-	 *
43
-	 * @param object $cipher one of the phpCrypt encryption cipher objects
44
-	 * @return void
45
-	 */
46
-	public function __construct($cipher)
47
-	{
48
-		parent::__construct(PHP_Crypt::MODE_CFB, $cipher);
49
-
50
-		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("CFB mode requires a block cipher", E_USER_WARNING);
53
-	}
54
-
55
-
56
-	/**
57
-	 * Destructor
58
-	 *
59
-	 * @return void
60
-	 */
61
-	public function __destruct()
62
-	{
63
-		parent::__destruct();
64
-	}
65
-
66
-
67
-	/**
68
-	 * Encrypts an the entire string $plain_text using the cipher passed
69
-	 *
70
-	 * @param string $text The string to be encrypted in CFB mode
71
-	 * @return boolean Returns true
72
-	 */
73
-	public function encrypt(&$text)
74
-	{
75
-		$max = strlen($text);
76
-		for($i = 0; $i < $max; ++$i)
77
-		{
78
-			// copy the register, and then encrypt it
79
-			$this->enc_register = $this->register;
80
-			$this->cipher->encrypt($this->enc_register);
81
-
82
-			// encrypt the byte
83
-			$text[$i] = $text[$i] ^ $this->enc_register[0];
84
-
85
-			// left shift the register and push the encrypted byte onto register
86
-			$this->register = substr($this->register, 1);
87
-			$this->register .= $text[$i];
88
-		}
89
-
90
-		return true;
91
-	}
92
-
93
-
94
-	/**
95
-	 * Decrypts an the entire string $plain_text using the cipher passed
96
-	 *
97
-	 * @param string $text the string to be decrypted in CFB mode
98
-	 * @return boolean Returns true
99
-	 */
100
-	public function decrypt(&$text)
101
-	{
102
-		$max = strlen($text);
103
-		for($i = 0; $i < $max; ++$i)
104
-		{
105
-			$this->enc_register = $this->register;
106
-			$this->cipher->encrypt($this->enc_register);
107
-
108
-			// left shift the register and push the encrypted byte onto register
109
-			$this->register = substr($this->register, 1);
110
-			$this->register .= $text[$i];
111
-
112
-			// decrypt the byte
113
-			$text[$i] = $text[$i] ^ $this->enc_register[0];
114
-		}
115
-
116
-		return true;
117
-	}
118
-
119
-
120
-	/**
121
-	 * This mode requires an IV
122
-	 *
123
-	 * @return boolean True
124
-	 */
125
-	public function requiresIV()
126
-	{
127
-		return true;
128
-	}
39
+    /**
40
+     * Constructor
41
+     * Sets the cipher object that will be used for encryption
42
+     *
43
+     * @param object $cipher one of the phpCrypt encryption cipher objects
44
+     * @return void
45
+     */
46
+    public function __construct($cipher)
47
+    {
48
+        parent::__construct(PHP_Crypt::MODE_CFB, $cipher);
49
+
50
+        // this works with only block Ciphers
51
+        if($cipher->type() != Cipher::BLOCK)
52
+            trigger_error("CFB mode requires a block cipher", E_USER_WARNING);
53
+    }
54
+
55
+
56
+    /**
57
+     * Destructor
58
+     *
59
+     * @return void
60
+     */
61
+    public function __destruct()
62
+    {
63
+        parent::__destruct();
64
+    }
65
+
66
+
67
+    /**
68
+     * Encrypts an the entire string $plain_text using the cipher passed
69
+     *
70
+     * @param string $text The string to be encrypted in CFB mode
71
+     * @return boolean Returns true
72
+     */
73
+    public function encrypt(&$text)
74
+    {
75
+        $max = strlen($text);
76
+        for($i = 0; $i < $max; ++$i)
77
+        {
78
+            // copy the register, and then encrypt it
79
+            $this->enc_register = $this->register;
80
+            $this->cipher->encrypt($this->enc_register);
81
+
82
+            // encrypt the byte
83
+            $text[$i] = $text[$i] ^ $this->enc_register[0];
84
+
85
+            // left shift the register and push the encrypted byte onto register
86
+            $this->register = substr($this->register, 1);
87
+            $this->register .= $text[$i];
88
+        }
89
+
90
+        return true;
91
+    }
92
+
93
+
94
+    /**
95
+     * Decrypts an the entire string $plain_text using the cipher passed
96
+     *
97
+     * @param string $text the string to be decrypted in CFB mode
98
+     * @return boolean Returns true
99
+     */
100
+    public function decrypt(&$text)
101
+    {
102
+        $max = strlen($text);
103
+        for($i = 0; $i < $max; ++$i)
104
+        {
105
+            $this->enc_register = $this->register;
106
+            $this->cipher->encrypt($this->enc_register);
107
+
108
+            // left shift the register and push the encrypted byte onto register
109
+            $this->register = substr($this->register, 1);
110
+            $this->register .= $text[$i];
111
+
112
+            // decrypt the byte
113
+            $text[$i] = $text[$i] ^ $this->enc_register[0];
114
+        }
115
+
116
+        return true;
117
+    }
118
+
119
+
120
+    /**
121
+     * This mode requires an IV
122
+     *
123
+     * @return boolean True
124
+     */
125
+    public function requiresIV()
126
+    {
127
+        return true;
128
+    }
129 129
 }
130 130
 ?>
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		parent::__construct(PHP_Crypt::MODE_CFB, $cipher);
49 49
 
50 50
 		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
51
+		if ($cipher->type() != Cipher::BLOCK)
52 52
 			trigger_error("CFB mode requires a block cipher", E_USER_WARNING);
53 53
 	}
54 54
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	public function encrypt(&$text)
74 74
 	{
75 75
 		$max = strlen($text);
76
-		for($i = 0; $i < $max; ++$i)
76
+		for ($i = 0; $i < $max; ++$i)
77 77
 		{
78 78
 			// copy the register, and then encrypt it
79 79
 			$this->enc_register = $this->register;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	public function decrypt(&$text)
101 101
 	{
102 102
 		$max = strlen($text);
103
-		for($i = 0; $i < $max; ++$i)
103
+		for ($i = 0; $i < $max; ++$i)
104 104
 		{
105 105
 			$this->enc_register = $this->register;
106 106
 			$this->cipher->encrypt($this->enc_register);
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@
 block discarded – undo
48 48
 		parent::__construct(PHP_Crypt::MODE_CFB, $cipher);
49 49
 
50 50
 		// this works with only block Ciphers
51
-		if($cipher->type() != Cipher::BLOCK)
52
-			trigger_error("CFB mode requires a block cipher", E_USER_WARNING);
51
+		if($cipher->type() != Cipher::BLOCK) {
52
+					trigger_error("CFB mode requires a block cipher", E_USER_WARNING);
53
+		}
53 54
 	}
54 55
 
55 56
 
Please login to merge, or discard this patch.
includes/libraries/Pdf/Tfpdf/font/zapfdingbats.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 block discarded – undo
4 4
 $up = -100;
5 5
 $ut = 50;
6 6
 $cw = array(
7
-	chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0,
8
-	chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939,
9
-	','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692,
10
-	'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776,
11
-	'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873,
12
-	'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317,
13
-	chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
14
-	chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788,
15
-	chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788,
16
-	chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918,
17
-	chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874,
18
-	chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0);
7
+    chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0,
8
+    chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939,
9
+    ','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692,
10
+    'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776,
11
+    'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873,
12
+    'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317,
13
+    chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
14
+    chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788,
15
+    chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788,
16
+    chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918,
17
+    chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874,
18
+    chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0);
19 19
 ?>
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 block discarded – undo
4 4
 $up = -100;
5 5
 $ut = 50;
6 6
 $cw = array(
7
-	chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0,
8
-	chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939,
9
-	','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692,
10
-	'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776,
11
-	'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873,
12
-	'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317,
13
-	chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
14
-	chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788,
15
-	chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788,
16
-	chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918,
17
-	chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874,
18
-	chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0);
7
+	chr(0)=>0, chr(1)=>0, chr(2)=>0, chr(3)=>0, chr(4)=>0, chr(5)=>0, chr(6)=>0, chr(7)=>0, chr(8)=>0, chr(9)=>0, chr(10)=>0, chr(11)=>0, chr(12)=>0, chr(13)=>0, chr(14)=>0, chr(15)=>0, chr(16)=>0, chr(17)=>0, chr(18)=>0, chr(19)=>0, chr(20)=>0, chr(21)=>0,
8
+	chr(22)=>0, chr(23)=>0, chr(24)=>0, chr(25)=>0, chr(26)=>0, chr(27)=>0, chr(28)=>0, chr(29)=>0, chr(30)=>0, chr(31)=>0, ' '=>278, '!'=>974, '"'=>961, '#'=>974, '$'=>980, '%'=>719, '&'=>789, '\''=>790, '('=>791, ')'=>690, '*'=>960, '+'=>939,
9
+	','=>549, '-'=>855, '.'=>911, '/'=>933, '0'=>911, '1'=>945, '2'=>974, '3'=>755, '4'=>846, '5'=>762, '6'=>761, '7'=>571, '8'=>677, '9'=>763, ':'=>760, ';'=>759, '<'=>754, '='=>494, '>'=>552, '?'=>537, '@'=>577, 'A'=>692,
10
+	'B'=>786, 'C'=>788, 'D'=>788, 'E'=>790, 'F'=>793, 'G'=>794, 'H'=>816, 'I'=>823, 'J'=>789, 'K'=>841, 'L'=>823, 'M'=>833, 'N'=>816, 'O'=>831, 'P'=>923, 'Q'=>744, 'R'=>723, 'S'=>749, 'T'=>790, 'U'=>792, 'V'=>695, 'W'=>776,
11
+	'X'=>768, 'Y'=>792, 'Z'=>759, '['=>707, '\\'=>708, ']'=>682, '^'=>701, '_'=>826, '`'=>815, 'a'=>789, 'b'=>789, 'c'=>707, 'd'=>687, 'e'=>696, 'f'=>689, 'g'=>786, 'h'=>787, 'i'=>713, 'j'=>791, 'k'=>785, 'l'=>791, 'm'=>873,
12
+	'n'=>761, 'o'=>762, 'p'=>762, 'q'=>759, 'r'=>759, 's'=>892, 't'=>892, 'u'=>788, 'v'=>784, 'w'=>438, 'x'=>138, 'y'=>277, 'z'=>415, '{'=>392, '|'=>392, '}'=>668, '~'=>668, chr(127)=>0, chr(128)=>390, chr(129)=>390, chr(130)=>317, chr(131)=>317,
13
+	chr(132)=>276, chr(133)=>276, chr(134)=>509, chr(135)=>509, chr(136)=>410, chr(137)=>410, chr(138)=>234, chr(139)=>234, chr(140)=>334, chr(141)=>334, chr(142)=>0, chr(143)=>0, chr(144)=>0, chr(145)=>0, chr(146)=>0, chr(147)=>0, chr(148)=>0, chr(149)=>0, chr(150)=>0, chr(151)=>0, chr(152)=>0, chr(153)=>0,
14
+	chr(154)=>0, chr(155)=>0, chr(156)=>0, chr(157)=>0, chr(158)=>0, chr(159)=>0, chr(160)=>0, chr(161)=>732, chr(162)=>544, chr(163)=>544, chr(164)=>910, chr(165)=>667, chr(166)=>760, chr(167)=>760, chr(168)=>776, chr(169)=>595, chr(170)=>694, chr(171)=>626, chr(172)=>788, chr(173)=>788, chr(174)=>788, chr(175)=>788,
15
+	chr(176)=>788, chr(177)=>788, chr(178)=>788, chr(179)=>788, chr(180)=>788, chr(181)=>788, chr(182)=>788, chr(183)=>788, chr(184)=>788, chr(185)=>788, chr(186)=>788, chr(187)=>788, chr(188)=>788, chr(189)=>788, chr(190)=>788, chr(191)=>788, chr(192)=>788, chr(193)=>788, chr(194)=>788, chr(195)=>788, chr(196)=>788, chr(197)=>788,
16
+	chr(198)=>788, chr(199)=>788, chr(200)=>788, chr(201)=>788, chr(202)=>788, chr(203)=>788, chr(204)=>788, chr(205)=>788, chr(206)=>788, chr(207)=>788, chr(208)=>788, chr(209)=>788, chr(210)=>788, chr(211)=>788, chr(212)=>894, chr(213)=>838, chr(214)=>1016, chr(215)=>458, chr(216)=>748, chr(217)=>924, chr(218)=>748, chr(219)=>918,
17
+	chr(220)=>927, chr(221)=>928, chr(222)=>928, chr(223)=>834, chr(224)=>873, chr(225)=>828, chr(226)=>924, chr(227)=>924, chr(228)=>917, chr(229)=>930, chr(230)=>931, chr(231)=>463, chr(232)=>883, chr(233)=>836, chr(234)=>836, chr(235)=>867, chr(236)=>867, chr(237)=>696, chr(238)=>696, chr(239)=>874, chr(240)=>0, chr(241)=>874,
18
+	chr(242)=>760, chr(243)=>946, chr(244)=>771, chr(245)=>865, chr(246)=>771, chr(247)=>888, chr(248)=>967, chr(249)=>888, chr(250)=>831, chr(251)=>873, chr(252)=>927, chr(253)=>970, chr(254)=>918, chr(255)=>0);
19 19
 ?>
Please login to merge, or discard this patch.
includes/libraries/Pdf/Tfpdf/font/courier.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,5 +4,5 @@
 block discarded – undo
4 4
 $up = -100;
5 5
 $ut = 50;
6 6
 for($i=0;$i<=255;$i++)
7
-	$cw[chr($i)] = 600;
7
+    $cw[chr($i)] = 600;
8 8
 ?>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,6 +3,6 @@
 block discarded – undo
3 3
 $name = 'Courier';
4 4
 $up = -100;
5 5
 $ut = 50;
6
-for($i=0;$i<=255;$i++)
6
+for ($i = 0; $i <= 255; $i++)
7 7
 	$cw[chr($i)] = 600;
8 8
 ?>
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,6 +3,7 @@
 block discarded – undo
3 3
 $name = 'Courier';
4 4
 $up = -100;
5 5
 $ut = 50;
6
-for($i=0;$i<=255;$i++)
6
+for($i=0;$i<=255;$i++) {
7 7
 	$cw[chr($i)] = 600;
8
+}
8 9
 ?>
Please login to merge, or discard this patch.