Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/songmu/math-checkdigits
Perl Module to generate and test check digits
https://github.com/songmu/math-checkdigits
Last synced: 2 days ago
JSON representation
Perl Module to generate and test check digits
- Host: GitHub
- URL: https://github.com/songmu/math-checkdigits
- Owner: Songmu
- License: other
- Created: 2010-05-25T16:57:08.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2013-04-15T14:46:51.000Z (over 11 years ago)
- Last Synced: 2024-10-11T21:09:53.938Z (27 days ago)
- Language: Perl
- Homepage:
- Size: 125 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
# NAME
Math::CheckDigits - Perl Module to generate and test check digits
# SYNOPSIS
use Math::CheckDigits;
my $cd = Math::CheckDigits->new(
modulus => 11,
weight => [2..7],
);
print $cd->checkdigit('12345678'); #5
print $cd->complete('12345678'); #123456785
print 'ok' if $cd->is_valid('123456785');set options
use Math::CheckDigits;
my $cd = Math::CheckDigits->new(
modulus => 10,
weight => [1, 2],
)->options(
runes => 1,
);print $cd->complete('348764') #3487649
advanced
# modulus 16
use Math::CheckDigits;
$cd = Math::CheckDigits->new(
modulus => 16,
weight => [1],
)->trans_table(
10 => '-',
11 => '$',
12 => ':',
13 => '.',
14 => '/',
15 => '+',
16 => 'a',
17 => 'b',
18 => 'c',
19 => 'd',
);
print $cd->checkdigit('a16329aa') # $;# DESCRIPTION
Math::CheckDigits is the Module for generating and testing check digits.
This module is similar to [Algorithm::CheckDigits](http://search.cpan.org/perldoc?Algorithm::CheckDigits). But, in this module, check digits can be computed from not format names (ex. JAN ISBN..), but two arguments, Modulus and Weight. This is the difference between [Algorithm::CheckDigits](http://search.cpan.org/perldoc?Algorithm::CheckDigits) and this module.
This module is effective to any check digits format using Modulus and Weight, and can't support the format that are generated from complicated algorithm.
# AUTHOR
Songmu
# SEE ALSO
[Algorithm::CheckDigits](http://search.cpan.org/perldoc?Algorithm::CheckDigits)
# LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.