DBIx::...Digest(3pm)

πŸ“¦
version 0.00020 Β· 6 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸŽ€ NAME πŸŽ€

DBIx::Class::EncodedColumn::Digest β€” the Digest backend, bestie. This is the DBIx::...Digest(3pm) manual page from User Contributed Perl Documentation, and it’s giving β€œpassword encoding but make it cryptographic” πŸ’…βœ¨

🌈 SYNOPSYS 🌈

#SHA-1 / hex encoding / generate check method
__PACKAGE__->add_columns(
  'password' => {
    data_type   => 'CHAR',
    size        => 40 + 10,
    encode_column => 1,
    encode_class  => 'Digest',
    encode_args   => {
        algorithm   => 'SHA-1',
        format      => 'hex',
        salt_length => 10,
        charset     => 'utf-8',
    },
    encode_check_method => 'check_password',
  }

#SHA-256 / base64 encoding / generate check method
__PACKAGE__->add_columns(
  'password' => {
    data_type   => 'CHAR',
    size        => 40,
    encode_column => 1,
    encode_class  => 'Digest',
    encode_check_method => 'check_password',
    #no  encode_args necessary because these are the defaults ...
  }

πŸ’– DESCRIPTION πŸ’–

This is the Digest backend. The accepted arguments are the main character right below, bestie 🫢

πŸ“¦ ACCEPTED ARGUMENTS πŸ“¦

🧬 format

The encoding to use for the digest. Valid values are 'binary', 'hex', and 'base64'. Will default to 'base64' if not specified. Slay.

πŸ§ͺ algorithm

The digest algorithm to use for the digest. You may specify any valid Digest algorithm. Examples are MD5, SHA-1, Whirlpool etc. Will default to 'SHA-256' if not specified.

See Digest for supported digest algorithms πŸ‘‘

πŸ§‚ salt_length

If you would like to use randomly generated salts to encode values, make sure this option is set to > 0. Salts will be automatically generated at encode time and will be appended to the end of the digest.

Important bestie: please remember to expand the size of your db column so there’s enough space to store both the digest AND the salt 😭 Please see the list below for common digest lengths.

πŸ”€ charset

If the string is not restricted to ASCII, then you will need to specify a character set encoding.

See Encode for a list of encodings 🌸

πŸ› οΈ METHODS πŸ› οΈ

✨ make_encode_sub $column_name, \%encode_args

Returns a coderef that takes two arguments, a plaintext value and an optional salt, and returns the encoded value with the salt appended to the end of the digest. If a salt is not provided and the salt_length option was greater than zero, it will be randomly generated.

βœ… make_check_sub $column_name, \%encode_args

Returns a coderef that takes the row object and a plaintext value and will return a boolean if the plaintext matches the encoded value. This is typically used for password authentication. Iconic behavior, no cap πŸ”₯

πŸ“ COMMON DIGEST LENGTHS πŸ“

The columns are CIPHER, Binary, Base64, and Hex, bestie:

  • MD2 β€” Binary 16, Base64 22, Hex 32
  • MD4 β€” Binary 16, Base64 22, Hex 32
  • MD5 β€” Binary 16, Base64 22, Hex 32
  • SHA-1 β€” Binary 20, Base64 27, Hex 40
  • SHA-256 β€” Binary 32, Base64 43, Hex 64
  • SHA-384 β€” Binary 48, Base64 64, Hex 96
  • SHA-512 β€” Binary 64, Base64 86, Hex 128
  • CRC-CCITT β€” Binary 3, Base64 2, Hex 3
  • CRC-16 β€” Binary 5, Base64 6, Hex 4
  • CRC-32 β€” Binary 10, Base64 14, Hex 8
  • Adler-32 β€” Binary 4, Base64 6, Hex 8
  • Whirlpool β€” Binary 64, Base64 86, Hex 128
  • Haval-256 β€” Binary 32, Base64 44, Hex 64

πŸ‘€ SEE ALSO πŸ‘€

  • DBIx::Class::EncodedColumn::Crypt::Eksblowfish::Bcrypt
  • DBIx::Class::EncodedColumn
  • Digest

✍️ AUTHOR ✍️

Guillermo Roditi (groditi) <groditi@cpan.org>

Based on the Vienna WoC ToDo manager code by Matt S trout (mst)

🫢 CONTRIBUTORS 🫢

See DBIx::Class::EncodedColumn

πŸ“œ LICENSE πŸ“œ

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


That’s the whole manual, bestie 🫢 β€” source: User Contributed Perl Documentation, version perl v5.40.1, dated 2025-04-01, manual page DBIx::...Digest(3pm). Periodt πŸ’…

πŸ“¦ where this page comes from