PHPackages                             stocker4all/luhn-mod-n - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. stocker4all/luhn-mod-n

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

stocker4all/luhn-mod-n
======================

luhn-mod-n is a very simple solution to generate and verify luhn mod n checksums. Possible bases (value for n) are between 2 and 36. Luhn mod 10 is well known from the credit card number checksum. But also in different bases it can be useful to have this checksum functionality.

v1.0(2y ago)050.5k↑117.9%MITPHP

Since Jan 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/mathiasstocker/luhn-mod-n)[ Packagist](https://packagist.org/packages/stocker4all/luhn-mod-n)[ RSS](/packages/stocker4all-luhn-mod-n/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

Luhn mod n
==========

[](#luhn-mod-n)

`luhn-mod-n` is a very simple solution to generate and verify luhn mod n checksums. Possible bases (value for n) are between 2 and 36. Luhn mod 10 is well known from the credit card number checksum. But also in different bases it can be useful to have this checksum functionality.

Example for base 2:
-------------------

[](#example-for-base-2)

Input

```
1001001100101100000001011010010

```

Output (number with checksum)

```
10010011001011000000010110100100

```

Example for base 10:
--------------------

[](#example-for-base-10)

Input

```
1234567890

```

Output (number with checksum)

```
12345678903

```

Example for base 16:
--------------------

[](#example-for-base-16)

Input

```
499602d2

```

Output (number with checksum)

```
499602d2f

```

Example for base 36:
--------------------

[](#example-for-base-36)

Input

```
kf12oi

```

Output (number with checksum)

```
kf12ois

```

Installing
----------

[](#installing)

You can use Composer to add the package to your project:

```
composer require stocker4all/luhn-mod-n

```

Usage example
-------------

[](#usage-example)

```
