Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
41 | 18 | public function hashData($data) |
|
42 | { |
||
43 | 18 | if (!is_string($data)) { |
|
1 ignored issue
–
show
|
|||
44 | 2 | throw new \InvalidArgumentException('The data for hashing must be a string or a binary string.'); |
|
45 | } |
||
46 | |||
47 | 16 | $data = $this->addSaltString($data); |
|
48 | |||
49 | 16 | $rawOutput = ($this->digestFormat === self::DIGEST_OUTPUT_RAW); |
|
50 | |||
51 | /** |
||
52 | * {@internal Backward compatibility algorithm for seed must be used. }} |
||
53 | */ |
||
54 | 16 | $digest = ($this->useNative) ? |
|
55 | 2 | \CryptoManana\Compatibility\NativeSha3::digest512($data, $rawOutput) |
|
56 | : |
||
57 | 16 | hash(static::ALGORITHM_NAME, $data, $rawOutput); |
|
58 | |||
59 | 16 | $digest = $this->changeOutputFormat($digest); |
|
60 | |||
61 | 16 | return $digest; |
|
62 | } |
||
64 |