Completed
Push — master ( 65cd04...b1e032 )
by Ramon
02:48
created

Util::getCipher()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Codecraft63\CertsignLogin;
4
5
trait Util
6
{
7
    private static function pkcs5_pad(string $text, \integer $blockSize): string
8
    {
9
        $pad = $blockSize - (strlen($text) % $blockSize);
10
        return $text . str_repeat(chr($pad), $pad);
11
    }
12
13
    private static function getCipher(): array
14
    {
15
        $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
16
        $cipher_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
17
18
        return [$cipher, $cipher_size];
19
    }
20
21
    private static function finalizeCipher($cipher) : null
22
    {
23
        mcrypt_generic_deinit($cipher);
24
        mcrypt_module_close($cipher);
25
    }
26
}
27