/
PBKDF2.pod
58 lines (35 loc) · 1.24 KB
/
PBKDF2.pod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
=begin pod
=TITLE class PKCS5::PBKDF2
=SUBTITLE
unit package PKCS5;
class PBKDF2 { ... }
=head1 Synopsis
use PKCS5::PBKDF2;
my PKCS5::PBKDF2 $p .= new;
my Str $spw = $p.derive-hex(
Buf.new('pencil'.encode),
Buf.new( 65, 37, 194, 71, 228, 58, 177, 233, 60, 109, 255, 118),
4096,
);
# returns '1d96ee3a529b5a5f9e47c01f229a2cb8a6e15f7d'
=head1 Methods
=head2 new
submethod BUILD (
Callable :$CGH = &sha1,
Int :$dklen,
)
Initialize the derivation function. The cryptographic hash function C<CGH> is
set to sha1 from the C<openSSL::Digest> by default. Other supported subs are
sha256 and md5 also from that module. Md5 can also be used from C<Digest::MD5>
but is very much slower.
C<Dklen> is the number of bytes output from the C<derive()> function. When not
given, it becomes the size of the output length of the C<CGH>.
=head2 derive
method derive ( Buf $pw, Buf $salt, Int $i --> Buf )
Calculate the derived key given the password C<$pw> and a salt C<$salt>. It
returns a Buf of length dklen specified to C<new()> when initializing.
=head2 derive-hex
method derive-hex ( Buf $pw, Buf $salt, Int $i --> Str )
Does the same as C<derive()> but converts the output Buf into a hexadecimal
string.
=end pod