Conditions | 6 |
Paths | 24 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
18 | public function __construct($options = []) |
||
19 | { |
||
20 | //Set default encryption key if none supplied |
||
21 | $key = isset($options['key']) ? $options['key'] : php_uname(); |
||
22 | |||
23 | $method = isset($options['method']) ? $options['method'] : false; |
||
24 | |||
25 | // convert ASCII keys to binary format |
||
26 | $this->key = ctype_print($key) ? openssl_digest($key, 'SHA256', true) : $key; |
||
27 | |||
28 | if ($method) { |
||
29 | if (\in_array(mb_strtolower($method), openssl_get_cipher_methods(), true)) { |
||
30 | $this->method = $method; |
||
31 | } else { |
||
32 | throw new CryptException("unrecognised cipher method: {$method}"); |
||
33 | } |
||
62 |