NAME
DBIO::EncodedColumn - One-way encode selected columns (e.g. passwords)
VERSION
version 0.900000
SYNOPSIS
package MyApp::Schema::Result::User;
use base 'DBIO::Core';
__PACKAGE__->load_components(qw/EncodedColumn/);
__PACKAGE__->add_columns(
password => {
data_type => 'varchar',
size => 255,
encode_column => 1,
encode_check_method => 'check_password',
encode_args => {
algorithm => 'SHA-256',
salt_length => 16,
},
},
);
my $user = $schema->resultset('User')->new_result({ password => 's3cret' });
$user->check_password('s3cret'); # true
DESCRIPTION
DBIO::EncodedColumn implements one-way column encoding for values like passwords. Columns are marked with encode_column => 1 in add_columns.
The value is encoded on the way to storage. Reading a column returns the stored (encoded) representation.
This component stores hashes using a stable format:
dbio$<algorithm>$<salt_base64>$<digest_base64>
and auto-installs a verifier method per encoded column.
COLUMN OPTIONS
encode_column-
Boolean; enables encoding for this column.
encode_check_method-
Method name to install for verification. Defaults to
check_${column}. encode_args-
Hashref with optional settings:
algorithm-
Digest algorithm name for Digest (default:
SHA-256, fallbackSHA-1). salt_length-
Salt size in bytes (default:
16,0disables salting).
RANDOMNESS
Salt generation prefers Crypt::URandom when installed, then /dev/urandom, and finally falls back to Perl rand() as a last resort.
For production password hashing, installing Crypt::URandom is recommended.
SEE ALSO
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.