Authen-Passphrase-Argon2

 view release on metacpan or  search on metacpan

lib/Authen/Passphrase/Argon2.pm  view on Meta::CPAN


=head1 SYNOPSIS

	use Authen::Passphrase::Argon2;

	$ppr = Authen::Passphrase::Argon2->new(
		salt_random => 1,
		hash_hex => '246172676f6e326924763d3139246d3d33323736382c743d332c703d312459574a6a5a47566d5a7a45794d7724435348383332634a6330347376516f7656492f754441',
	);

	$algorithm = $ppr->algorithm;
	$salt = $ppr->salt;
	$salt_hex = $ppr->salt_hex;
	$hash = $ppr->hash;
	$hash_hex = $ppr->hash_hex;

	if($ppr->match($passphrase)) {
		...
	}

	$userPassword = $ppr->as_crypt;

	.....

	__PACKAGE__->add_columns(

	);

=cut

=head2 NOTE

This is an attempt to make L<Crypt::Argon2> compliant with L<Authen::Passphrase>.
The term **hash** is loosely used in this documentation and implementation. Really when we say hash/hex we are dealing with an Argon2 cryptographic key. consistency.

=cut

=head1 Methods

=cut

=head2 Authen::Passphrase::Argon2->new

params

	# Only one of these must be defined for the salt value. An error will be thrown if none or more than one is defined.
	salt - plain text salt value
	salt_hex - salt in hex value that gets decoded.
	salt_base64 - salt value encoded in base64 that gets decoded.
	salt_random - a random salt will be generated using Data::GUID.

	# Only one of these must be defined for the crypt value. An error will be thrown if none or more than one is defined.
	passphrase - plain text passpord that will be converted to argon2
	hash - plain text argon2 value
	hash_base64 - base64 encoded argon2 value
	hash_hex - hex decimal argon2 value

	# optional params
	cost - optional - default 3 - This is the time-cost factor, typically a small integer that can be derived as explained above.
	factor - optional - default '32M' - This is the memory costs factor. This must be given as a integer followed by an order of magnitude (k, M or G for kilobytes, megabytes or gigabytes respectively), e.g. '64M'.
	parallelism - optional - default 1 - This is the number of threads that are used in computing it.
	size - optional - default 16 - This is the size of the raw result in bytes. Typical values are 16 or 32.

=cut

=head2 $ppr->algorithm

Returns the algorithm, in the same form as supplied to the constructor. Which will always be Argon2

=cut

=head2 $ppr->salt

Returns the salt, in raw form.

=cut

=head2 $ppr->salt_hex

Returns the salt, as a string of hexadecimal digits.

=cut

=head2 $ppr->salt_base64

Returns the salt, as a string encoded in base64.

=cut

=head2 $ppr->as_crypt

Returns the raw argon2 formatted string.

=cut

=head2 $ppr->as_hex

Returns the raw argon2 formatted string in hex format.

=cut

=head2 $ppr->as_base64

Returns the raw argon2 formatted string encdoed in base64.

=cut

=head2 $ppr->hash

Returns the hash value, in raw form.

(lets keep consistency but it's just an alias for as_crypt, perhaps I have some misunderstanding /o\)

=cut

=head2 $ppr->hash_hex

Returns the hash value, as a string of hexadecimal digits.

=cut



( run in 2.176 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )