Code Duplication    Length = 35-36 lines in 2 locations

includes/libraries/phpcrypt/ciphers/Rijndael.php 2 locations

@@ 179-214 (lines=36) @@
176
     * @param string @text The string to encrypt
177
     * @return boolean Returns true
178
     */
179
    public function encrypt(&$text)
180
    {
181
        // set the operation to decryption
182
        $this->operation(parent::ENCRYPT);
183
184
        $loops = 0;
185
        $key_sz = $this->keySize();
186
        $blk_sz = $this->blockSize();
187
188
        // if the key and block size is 16, do 10 rounds
189
        // if the key or block size is 24, and neither is longer than 24, do 12 rounds
190
        // if either key or block size is 32, do 14 rounds
191
        if ($key_sz == 16 && $blk_sz == 16) {
192
                    $loops = 10;
193
        } else if (($key_sz == 24 || $blk_sz == 24) && $key_sz <= 24 && $blk_sz <= 24) {
194
                    $loops = 12;
195
        } else if ($key_sz == 32 || $blk_sz == 32) {
196
                    $loops = 14;
197
        }
198
199
        // now begin the encryption
200
        $this->addRoundKey($text, 0);
201
202
        for ($i = 1; $i <= $loops; ++$i)
203
        {
204
            $this->byteSub($text);
205
            $this->shiftRow($text);
206
207
            // the last iteration does not use mixColumn
208
            if ($i < $loops) {
209
                            $this->mixColumn($text);
210
            }
211
212
            $this->addRoundKey($text, $i);
213
        }
214
215
        return true;
216
    }
217
@@ 225-259 (lines=35) @@
222
     * @param string @text The string to decrypt
223
     * @return boolean Returns true
224
     */
225
    public function decrypt(&$text)
226
    {
227
        // set the operation to decryption
228
        $this->operation(parent::DECRYPT);
229
230
        $loops = 0;
231
        $key_sz = $this->keySize();
232
        $blk_sz = $this->blockSize();
233
234
        // if the key and block size is 16, do 10 rounds
235
        // if the key or block size is 24, and neither is longer than 24, do 12 rounds
236
        // if either key or block size is 32, do 14 rounds
237
        if ($key_sz == 16 && $blk_sz == 16) {
238
                    $loops = 10;
239
        } else if (($key_sz == 24 || $blk_sz == 24) && $key_sz <= 24 && $blk_sz <= 24) {
240
                    $loops = 12;
241
        } else if ($key_sz == 32 || $blk_sz == 32) {
242
                    $loops = 14;
243
        }
244
245
        // now begin the decryption
246
        $this->addRoundKey($text, 0);
247
248
        for ($i = 1; $i <= $loops; ++$i)
249
        {
250
            $this->shiftRow($text);
251
            $this->byteSub($text);
252
            $this->addRoundKey($text, $i);
253
254
            // the last iteration does not use mixColumn
255
            if ($i < $loops) {
256
                            $this->mixColumn($text);
257
            }
258
        }
259
260
        return true;
261
    }
262