NAME Crypt::PostgreSQL - Module for generating encrypted password for PostgreSQL

VERSION

version 0.01

SYNOPSIS

use Crypt::PostgreSQL;

print Crypt::PostgreSQL::encrypt_md5('my password', 'myuser');

my $scram_hash = Crypt::PostgreSQL::encrypt_scram('my password');
my DBI;
my $dbh = DBI->connect("dbi:Pg:dbname=...", '', '', {AutoCommit => 0});
$dbh->do(q{
    ALTER USER my_user SET ECRYPTION PASSWORD '$scram_hash';
});

DESCRIPTION

This module is for generating password suitable to generate password hashes in PostgreSQL format, using one of the two encrypted formats: scram_sha_256 and md5

BUGS

Please let the author know if any are caught

AUTHOR

Guido Brugnara
gdo@leader.it

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

https://www.postgresql.org/docs/current/auth-password.html

PostgreSQL documentation: 20.5. Password Authentication

= iten https://www.leader.it/Blog/PostgreSQL_SCRAM-SHA-256_authentication

Blog article: PostgreSQL SCRAM-SHA-256 authentication with credits ...

encrypt_md5

The 1st argument is the password to encrypted

The 2th argument is the postgresgl user name

The function returns hash string suitable to use with ALTER USER SQL command.

encrypt_scram

The 1st argument is the password to encrypted

The 2nd argument, can define salt (use only for test!)

The function returns hash string suitalbe to use with ALTER USER SQL command.