LegacyEncryptor::decrypt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.064

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
ccs 3
cts 5
cp 0.6
cc 1
eloc 6
nc 1
nop 2
crap 1.064
1
<?php
2
3
namespace Carnage\EncryptedColumn\Encryptor;
4
5
use Carnage\EncryptedColumn\Exception\PopArtPenguinException;
6
use Carnage\EncryptedColumn\ValueObject\EncryptorIdentity;
7
use Carnage\EncryptedColumn\ValueObject\IdentityInterface;
8
use Carnage\EncryptedColumn\ValueObject\Key;
9
use phpseclib\Crypt\Base;
10
use phpseclib\Crypt\Rijndael;
11
12
class LegacyEncryptor implements EncryptorInterface
13
{
14
    const IDENTITY = 'legacy';
15
16
    public function encrypt($data, Key $key)
17
    {
18
        throw new PopArtPenguinException();
19 1
    }
20
21 1
    public function decrypt($data, Key $key)
22 1
    {
23
        $cipher = new Rijndael(Base::MODE_ECB);
24
        $cipher->setBlockLength(256);
25
        $cipher->setKey($key->getKeyInfo());
26
        $cipher->padding = false;
27
28
        return trim($cipher->decrypt(base64_decode($data)));
29 1
    }
30
31 1
    public function getIdentifier(): IdentityInterface
32 1
    {
33 1
        return new EncryptorIdentity(self::IDENTITY);
34
    }
35
}