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

MCryptEncryptor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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