Monday, October 29, 2007

Verhoeff checksum algorithm in Python

I've written a python implementation of the Verhoeff checksum algorithm. You can download it as verhoeff.zip or verhoeff.tgz . Please try it and tell me what you think. Here's the canonical usage example. Calculate the checkdigit for 142857.
>>> from verhoeff import Verhoeff
>>> v = Verhoeff()
>>> v.calcsum(142857)
0
>>> v.checksum(1428570)
0
Alternatively, it can be invoked as a command as follows:
python verhoeff.py 142857
1428570




No comments: