npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

elfproef

v1.1.0

Published

Implementation of the 11-proof, a mathematical test used by the Dutch government for various digital identification numbers

Downloads

790

Readme

Elfproef (11-proof)

Travis CI Version Dependencies License


Implementation of the 11-proof, a mathematical test used by the Dutch government for various digital identification numbers


Description

Explanation

Elfproef is Dutch for 11-proof (elf means 11, proef means test). It was originally designed to prevent people from trying to transfer money to a mistyped account number, specifically where either one digit is incorrect, or 2 digits were swapped.

The principle is very simple. First of all, a given number is split into its individual digits. Secondly, those digits are multiplied by their "weight", a multiplier which is based on the position of the digit. Finally, the sum of all multiplied numbers is calculated.

If the result is divisible by 11 and greater than 0, the 11-proof is valid.

Example

A Dutch social security number (BSN) consists of 9 digits and must suffice the 11-proof with weights [9, 8, 7, 6, 5, 4, 3, 2, -1]. Sometimes the BSN can also consist of 8 digits, which is usually converted to 9 digits by adding a leading zero.

For a given BSN ABCDEFGHI, the outcome of the following formula must be divisble by 11 and have no more than one leading zero.

(9 × A) + (8 × B) + (7 × C) + (6 × D) + (5 × E) + (4 × F) + (3 × G) + (2 × H) + (-1 × I)

A valid BSN would be 111222333.

(9 × 1) + (8 × 1) + (7 × 1) + (6 × 2) + (5 × 2) + (4 × 2) + (3 × 3) + (2 × 3) + (-1 × 3) = 66

The result is divisible by 11:

66 > 0 66 ∧ 66 mod 11 = 0

Usage

Installation

yarn add elfproef -E

Example

import { validateBSN } from 'elfproef';

const BSN = "111222333";
const validBSN = validateBSN(BSN);

console.log(validBSN);

Functions

elfProef(input: string | number, weights: number[], positiveSum: boolean): boolean

The first argument is the input string or number which will be tested. The second argument is an array containing the weights which will be used to multiply each digit, which means the length of this array should be equal to the input length. The third argument adds an additional check for making sure the resulting sum is greater than zero, which is not used for the BSN, but was needed for checking dutch banking numbers before the IBAN system was implemented. This functions returns a boolean indicating whether the check was successful.

validateBSN(input: string | number): boolean

This function will validate a BSN as shown in the example above. The input can be either a string or a number, and the return value will be a boolean indicating whether the provided input is a valid BSN.

generateBSN(): string

This function generates a random valid BSN and returns it as a string.

References

  • https://nl.wikipedia.org/wiki/Elfproef
  • https://nl.wikipedia.org/wiki/Burgerservicenummer
  • https://www.rijksoverheid.nl/onderwerpen/privacy-en-persoonsgegevens/vraag-en-antwoord/wat-is-het-burgerservicenummer-bsn

License

This project is licensed under the MIT License.