Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
doc
 
 
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

README.md

mod11

travis-ci status

Lua modulo11 number generator and verificator Modulo 11 is a way to calculate checksums for digitbased codes. Common usage for modulo 11 is ISBN, credit card or bank account numbers. The verification offered is not intended for security, but to catch human errors (typo's). See this wikipedia article.

API documentation is available online at github as is the source code

General usage

Modulo 11 calculates a checksum based on a weight given to digits based upon their position. The verifycode must be supplied once, and checking numbers can be done against the same verifycode. This implementation uses a verifycode 8 characters long, digits 2-9 (no duplicates). This means that for every 8 input digits 1 checksum digit is added. Different series of numbers can be used with different verifycodes.

For readability 'allowed' characters can be provided. When calculating or verifying checksums those characters are ignored. Common 'allowed' characters are "-/.". With this set of allowed characters the following sequences will get the same checksums;

  • 2012.345.67/32
  • 2012-345/67.32
  • 20123456732

Examples

Using an invoicenumber containing a date and a sequential number that can be represented like this: "2013-12-15/015". The allowed characters must be "-/" in this case.

local invoice = "2013-12-15/015"
print(m:calc(invoice.."-"))

The above example will print the invoice number 2013-12-15/015-xx where xx is the checksum depending on the verifynumber initially choosen for this sequence.

Searching

The module contains an iterator function that can scan text for valid numbers. Sample use includes checking incoming emails for valid supportcase numbers, or scanning bank transaction details for valid invoice numbers or customerids. For an example see the sample.lua file. The sample contains 2 series with their own verifynumber sequence, where each iterator will only find its own numbers.

Tests

Testsuite is included in the spec folder and can be executed using busted.

License

MIT

About

Lua modulo11 number generator and verificator

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.