Completed
Push — master ( cf496c...a42f10 )
by Michael
17:56 queued 16:33
created

OpensslBridge::encrypt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * OpensslBridge.php.
7
 *
8
 * PHP version 7
9
 *
10
 * @category Dcrypt
11
 *
12
 * @author   Michael Meyer (mmeyer2k) <[email protected]>
13
 * @license  http://opensource.org/licenses/MIT The MIT License (MIT)
14
 *
15
 * @link     https://github.com/mmeyer2k/dcrypt
16
 */
17
18
namespace Dcrypt;
19
20
/**
21
 * Provides functionality common to the dcrypt AES block ciphers.
22
 * Extend this class to customize your cipher suite.
23
 *
24
 * @category Dcrypt
25
 *
26
 * @author   Michael Meyer (mmeyer2k) <[email protected]>
27
 * @license  http://opensource.org/licenses/MIT The MIT License (MIT)
28
 *
29
 * @link     https://github.com/mmeyer2k/dcrypt
30
 */
31
class OpensslBridge
32
{
33
    /**
34
     * Decrypt ciphertext.
35
     *
36
     * @param string $data Ciphertext to decrypt
37
     * @param string $key  Key which will be used to decrypt data
38
     *
39
     * @return string
40
     */
41 28
    public static function decrypt(string $data, string $key): string
42
    {
43 28
        return OpensslStatic::decrypt($data, $key, static::CIPHER, static::ALGO);
44
    }
45
46
    /**
47
     * Encrypt plaintext.
48
     *
49
     * @param string $data Plaintext string to encrypt.
50
     * @param string $key  Key which will be used to encrypt data
51
     *
52
     * @return string
53
     */
54 28
    public static function encrypt(string $data, string $key): string
55
    {
56 28
        return OpensslStatic::encrypt($data, $key, static::CIPHER, static::ALGO);
57
    }
58
}
59