Completed
Push — master ( d044a7...7ba68a )
by Florent
03:57
created

MCryptEncryptor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 25
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A encrypt() 0 4 1
A decrypt() 0 4 1
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace AESKW;
13
14
final class MCryptEncryptor implements EncryptorInterface
15
{
16
    private $kek;
17
18
    public function __construct($kek)
19
    {
20
        $this->kek = $kek;
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function encrypt($data)
27
    {
28
        return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->kek, $data, MCRYPT_MODE_ECB);
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function decrypt($data)
35
    {
36
        return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $this->kek, $data, MCRYPT_MODE_ECB);
37
    }
38
}
39