Crypt::PBE::PBKDF1 - Perl extension for PKCS #5 Password-Based Key Derivation Function 1 (PBKDF1)
use Crypt::PBE::PBKDF1; # OO style my $pbkdf1 = Crypt::PBE::PBKDF1->new( password => $password, salt => $salt, hash => 'sha1' ); $pbkdf1->derived_key; # Byte $pbkdf1->derived_key_base64 # Base64 encoded $pbkdf1->derived_key_hex # Hex use Crypt::PBE::PBKDF1 qw(pbkdf1_md2 pbkdf1_md5_base64 pbkdf1_sha1_hex); # Functional style $derived_key = pbkdf1 ( %params ); # Byte $derived_key = pbkdf1_base64 ( %params ); # Base64 encoded $derived_key = pbkdf1_hex ( %params ); # Hex # Functional style helpers $derived_key = pbkdf1_md2 ( %params ); $derived_key = pbkdf1_md2_hex ( %params ); $derived_key = pbkdf1_md2_base64 ( %params ); $derived_key = pbkdf1_md5 ( %params ); $derived_key = pbkdf1_md5_hex ( %params ); $derived_key = pbkdf1_md5_base64 ( %params ); $derived_key = pbkdf1_sha1 ( %params ); $derived_key = pbkdf1_sha1_hex ( %params ); $derived_key = pbkdf1_sha1_base64 ( %params );
PBKDF2 applies a pseudorandom function, such as hash-based message authentication code (HMAC), to the input password or passphrase along with a salt value and repeats the process many times to produce a derived key, which can then be used as a cryptographic key in subsequent operations.
Params:
password : The password to use for the derivation
password
salt : The salt to use for the derivation. This value should be generated randomly.
salt
hash : Hash algorithm (default "sha1")
hash
count : The number of internal iteractions to perform for the derivation key (default "1_000")
count
Return the derived key in raw output (byte).
Return the derived key in Base64 encoded format.
Return the derived key in HEX format.
Return the hash name.
Return the iteration count number.
Return the derived key length.
Return derived key using PBKDF1 function:
my $derived_key = pbkdf1 ( hash => 'sha1', password => 'mypassword', salt => my_random_byte_sub(), count => 2_000 ); print length($derived_key) # 20
Return derived key in Base64 using PBKDF1 function.
Return derived key in HEX using PBKDF1 function.
Return the derived key using MD2, MD5 and SHA1 digest:
Return the derived key using MD2, MD5 and SHA1 digest in Base64:
Return the derived key using MD2, MD5 and SHA1 digest in HEX:
Please report any bugs or feature requests through the issue tracker at https://github.com/giterlizzi/perl-Crypt-PBE/issues. You will be notified automatically of any progress on your issue.
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://github.com/giterlizzi/perl-Crypt-PBE
git clone https://github.com/giterlizzi/perl-Crypt-PBE.git
Giuseppe Di Terlizzi <gdt@cpan.org>
This software is copyright (c) 2020-2023 by Giuseppe Di Terlizzi.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Crypt::PBE, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Crypt::PBE
CPAN shell
perl -MCPAN -e shell install Crypt::PBE
For more information on module installation, please visit the detailed CPAN module installation guide.