cryptal
latest
Cryptography Abstraction Layer
Main Page
Classes
Files
File List
Hash.php
1
<?php
2
3
namespace
fpoirotte\Cryptal\DefaultAlgorithms
;
4
5
use
fpoirotte\Cryptal\Implementers\AbstractHash
;
6
use
fpoirotte\Cryptal\HashEnum
;
7
8
class
Hash
extends
AbstractHash
9
{
10
private
$func;
11
private
$data;
12
13
public
function
__construct
(
HashEnum
$algorithm)
14
{
15
$supported = array(
16
'md5'
=> HashEnum::HASH_MD5(),
17
'sha1'
=> HashEnum::HASH_SHA1(),
18
);
19
20
$func = array_search($algorithm, $supported);
21
if
(
false
=== $func) {
22
throw
new \InvalidArgumentException(
'Unsupported algorithm'
);
23
}
24
25
$this->func = $func;
26
$this->data =
''
;
27
}
28
29
protected
function
internalUpdate($data)
30
{
31
$this->data .= $data;
32
}
33
34
protected
function
internalFinalize()
35
{
36
return
call_user_func($this->func, $this->data,
true
);
37
}
38
}
fpoirotte\Cryptal\Implementers\AbstractHash
Definition:
AbstractHash.php:12
fpoirotte\Cryptal\DefaultAlgorithms
Definition:
Camellia.php:3
fpoirotte\Cryptal\HashEnum
Definition:
HashEnum.php:10
fpoirotte\Cryptal\DefaultAlgorithms\Hash
Definition:
Hash.php:8
fpoirotte\Cryptal\DefaultAlgorithms\Hash\__construct
__construct(HashEnum $algorithm)
Definition:
Hash.php:13
AbstractHash
HashEnum
src
Cryptal
DefaultAlgorithms
Hash.php
Generated on Sat Sep 29 2018 22:22:05 for cryptal by
1.8.11