Decrypt   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 1
f 0
dl 0
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A token() 0 11 4
1
<?php
2
3
namespace Mfonte\Base62x\Encryption\Cypher;
4
5
class Decrypt
6
{
7
    public static function token($data, $method, $key)
8
    {
9
        $iv_strlen = 2 * Bytes::iv($method);
10
        if (preg_match('/^(.{'.$iv_strlen.'})(.+)$/', $data, $regs)) {
11
            list(, $iv, $crypted_string) = $regs;
12
            if (ctype_xdigit($iv) && mb_strlen($iv) % 2 == 0) {
13
                return openssl_decrypt($crypted_string, $method, $key, 0, hex2bin($iv));
14
            }
15
        }
16
17
        return false; // failed to decrypt
18
    }
19
}
20