NAME

Crypt::Credentials - Manage credential files

VERSION

version 0.001

SYNOPSIS

my $credentials = Crypt::Credentials->new(
  dir => $dir,
  key => $ENV{CREDENTIAL_KEY},
);

my $password = $credentials->get('password');

DESCRIPTION

This module implements a credentials store. Essentially it allows you to expand one secret (the key of the store) into any number of secrets.

METHODS

new

$self->new(key => $key, dir => $dir)

This creates a new Crypt::Credentials object. It takes two named arguments: $key (mandatory) is the cryptographic key used to encrypt the credentials, it must be either 16, 24, or 32 bytes long. $dir is optional for the directory in which the credentials are stored, it defaults to ./credentials.

get

$self->get($name)

This reads the credentials entry for $name, or throws an exception if it can't be opened for any reason.

get_yaml

$self->get_yaml($name)

Like the above, except it will decode the payload as YAML.

put

$self->put($name, $value)

This will write the values to the named credentials entry.

put_yaml

$self->put_yaml($name, \%values)

Like the above, but it will encode the value to YAML first.

has

$self->has($name)

This checks if a credentials entry exists

remove

$self->remove($name)

This removes a credentials entry. It will silently succeed if no such entry exists.

list

$self->list

This will list all credential entries.

recode

$self->recode($new_key)

This will recode all credential entries from the current key to the new one.

AUTHOR

Leon Timmermans <fawaka@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by Leon Timmermans.

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