Completed
Push — master ( d724e7...4ddcf1 )
by Ramon
15:58
created

Util   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 22
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCipher() 0 7 1
A finalizeCipher() 0 5 1
A pkcs5Pad() 0 5 1
1
<?php
2
3
namespace Codecraft63\CertsignLogin;
4
5
trait Util
6
{
7
    private static function pkcs5Pad(string $text, $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)
22
    {
23
        mcrypt_generic_deinit($cipher);
24
        mcrypt_module_close($cipher);
25
    }
26
}
27