NAME
OpenSearch::Client::Hash - A utility to create password hashes
VERSION
version 3.007010
SYNOPSYS
use OpenSearch::Client::Hash;
my $pwdhasher = OpenSearch::Client::Hash->new;
my $hash1 = $pwdhasher->create_bcrypt_password_hash( password => 'my plaintext password');
my $hash2 = $pwdhasher->create_argon2_password_hash( password => 'my plaintext password');
my $hash3 = $pwdhasher->create_pbkdf2_password_hash( password => 'my plaintext password');
# store $hash1
# $hash1 == something like $2y$12$KCHnaCykMhrXNkfpPlDmRejRYAd2rhixnWgcpICQyTEc8HI.0G8Ca
# later create users using stored hashed passwords
my $cli = OpenSearch::Client->new( .... );
my $result = $cli->security->patch_users(
body => [
{
op => 'add',
path => '/myuserone',
value => {
description => 'Read only query user',
hash => '$2y$12$KCHnaCykMhrXNkfpPlDmRejRYAd2rhixnWgcpICQyTEc8HI.0G8Ca'
}
},
{
op => 'add',
path => '/myusertwo',
value => {
description => 'Indexing user',
hash => '$2y$12$ak6pPjW3aEbVaU7FX03HLuGWO0K5oNa3PRvUE.A6six2vdvq0uTue'
}
},
]
);
DESCRIPTION
Allows creation of BCrypt, Argon2 and PBKDF2 password hashes that can be stored for later use in user creation.
These are the same types of hash produced by plugins/opensearch-security/tools/hash.sh -p <new-password>.
METHODS
create_bcrypt_password_hash
Create a BCrypt password hash from a plain text password.
You cannot use hashes produced by this method if your plugins.security.password.hashing.algorithm is not the default BCrypt
use OpenSearch::Client::Hash;
my $ph = OpenSearch::Client::Hash->new;
my $hash1 = $ph->create_bcrypt_password_hash( password => 'my plaintext password' );
my $hash2 = $ph->create_bcrypt_password_hash(
password => 'my other plaintext password',
type => '2y',
rounds => 12
);
password-
Required. The plaintext password to hash.
Note that in
BCryptpasswords may only contain 72 characters and may not contain any null-byte. type-
Optional. Default is '2y'. Allowed values are '2y', '2a' and '2b'.
Specifies the minor version of the
BCryptalgorithm to use for hashing.Do not set this option unless your
plugins.security.password.hashing.bcrypt.minorsetting is not the defaultYwhen you must match it with2aforAand2bforB. rounds-
Optional. Default is 12.
Specifies the number of rounds to use for password hashing with
BCrypt. Valid values are between 4 and 31, inclusive.Do not set this option unless your
plugins.security.password.hashing.bcrypt.roundssetting is something other than 12 when you must match it here.
create_argon2_password_hash
Create an Argon2 password hash from a plain text password.
You cannot use hashes produced by this method unless :
your
plugins.security.password.hashing.algorithmisArgon2your
plugins.security.password.hashing.argon2.versionis the default19
use OpenSearch::Client::Hash;
my $ph = OpenSearch::Client::Hash->new;
my $hash1 = $ph->create_argon2_password_hash( password => 'my plaintext password' );
my $hash2 = $ph->create_argon2_password_hash(
password => 'my other plaintext password',
type => 'argon2id',
length => 32,
iterations => 3,
memory => 65536,
);
password-
Required. The plaintext password to hash.
type-
Optional. Default is 'argon2id'. Allowed values are 'argon2id', 'argon2i' and 'argon2d'.
Do not set this option unless your
plugins.security.password.hashing.argon2.typesetting is not the defaultArgon2idwhen you must match it here. length-
Optional. Desired length of the final derived key. Default is 32.
Do not set this option unless your
plugins.security.password.hashing.argon2.lengthsetting is not the default32when you must match it here. iterations-
Optional. Number of times the pseudo-random function is applied to the password. Default is 3.
Do not set this option unless your
plugins.security.password.hashing.argon2.iterationssetting is not the default3when you must match it here. memory-
Optional. Amount of memory to use for hashing in KiB. Default is 65536.
Do not set this option unless your
plugins.security.password.hashing.argon2.memorysetting is not the default65536when you must match it here.
create_pbkdf2_password_hash
Create a PBKDF2 password hash from a plain text password.
You cannot use hashes produced by this method unless your plugins.security.password.hashing.algorithm is PBKDF2
use OpenSearch::Client::Hash;
my $ph = OpenSearch::Client::Hash->new;
my $hash1 = $ph->create_pbkdf2_password_hash( password => 'my plaintext password' );
my $hash2 = $ph->create_pbkdf2_password_hash(
password => 'my other plaintext password',
function => 'SHA256',
length => 256,
iterations => 600000,
);
password-
Required. The plaintext password to hash.
function-
Optional. Default is 'SHA256'. Allowed values are 'SHA1', 'SHA224', 'SHA256', 'SHA384' and 'SHA512'.
Do not set this option unless your
plugins.security.password.hashing.pbkdf2.functionsetting is not the defaultSHA256when you must match it here. length-
Optional. Desired length of the final derived key. Default is 256.
Do not set this option unless your
plugins.security.password.hashing.pbkdf2.lengthsetting is not the default256when you must match it here. iterations-
Optional. Number of times the pseudo-random function is applied to the password. Default is 600000.
Do not set this option unless your
plugins.security.password.hashing.pbkdf2.iterationssetting is not the default600000when you must match it here.
MANUAL
Documentation index OpenSearch::Client::Manual
AUTHOR
Mark Dootson <mdootson@cpan.org> ( current maintainer )
COPYRIGHT AND LICENSE
Copyright (C) 2026 by Mark Dootson
This is free software, licensed under:
The Apache License, Version 2.0, January 2004