php-extended / php-checksum-luhn
This package is abandoned and no longer maintained.
The author suggests using the php-extended/php-checksum-object package instead.
A library that implements the php-extended/php-checksum-interface for the luhn algorithm
6.0.5
2023-08-21 18:46 UTC
Requires
- php: >=7.4
- php-extended/php-checksum-interface: ^6
- php-extended/polyfill-php80-stringable: ^1.2
Requires (Dev)
This package is auto-updated.
Last update: 2023-08-22 18:28:41 UTC
README
A library that implements the php-extended/php-checksum-interface for the luhn algorithm.
Installation
The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.
- Download
composer.phar
from their website. - Then run the following command to install this library as dependency :
php composer.phar php-extended/php-checksum-luhn ^6
Basic Usage
You may use this library the following way :
use PhpExtended\Checksum\ChecksumLuhn;
$checksum = new ChecksumLuhn();
$data = '<put your digit string here>';
$checked = $checksum->matches(substr($data, 0, -1), substr($data, -1));
// returns true if verified
$signed = $data.$checksum->calculate($data);
// appends the calculated digit to the checksum
License
MIT (See license file).