damm64
v1.0.0
Published
Base64 (base64url) implementation of the Damm check digit algorithm
Maintainers
Readme
damm64: base64url Damm check digits
The Damm algorithm is a check digit algorithm that detects every single-character error and every adjacent transposition. Prepending leading zeros does not change the check digit.
damm64 applies it to the base64url alphabet (RFC 4648 §5), with matching implementations in C, PHP and JavaScript. Each one is a library plus a command-line tool, and all three give identical output.
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_Base64 zero is A. Input is case-sensitive.
Usage
npm install damm64import { checkDigit, isValid, value, INVALID } from 'damm64';
checkDigit('Hello'); // 'p', or INVALID (null)
isValid('Hellop'); // true
value('H'); // 0-63, or -1 if not in the alphabetThe package is a dependency-free ES module with TypeScript declarations, and includes the damm64 command (npx damm64). C and PHP implementations with identical output are in the GitHub repository.
Licence
BSD 2-Clause
