Skip to content

Latest commit

 

History

History
62 lines (40 loc) · 1.91 KB

README.md

File metadata and controls

62 lines (40 loc) · 1.91 KB

Luhn Algorithms

Modulus-10 algorithms for validation and generation

CI License Maven Central

This is a simple library utilising core Java for Modulus-10 algorithms. You can simply validate a number if provided as long or String. The latter is parsed into long primitive. You can also generate your own valid Luhn number, which is returned as long.

Dependency

Maven
<dependency>
    <groupId>com.vangogiel.luhnalgorithms</groupId>
    <artifactId>luhn-algorithms</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

dependencies {
    implementation 'com.vangogiel.luhnalgorithms:luhn-algorithms:1.0.0'
}

Usage

// Validation
LuhnAlgorithms.isValid(4716881992809921L) // Valid Luhn

LuhnAlgorithms.isValid(4716881992809922L) // Invalid Luhn

LuhnAlgorithms.isValid("4716881992809921") // Valid Luhn

LuhnAlgorithms.isValid("4716881992809922") // Invalid Luhn

// Generation
LuhnAlgorithms.generateLuhnFromRange(111, 2, 5); // Returns for example 14233

LuhnAlgorithms.generateRandomLuhn(6); // Returns for example 136820

Versioning

Semantic Versioning is used for versioning.

Changelog

For a complete list of changes, and how to migrate between major versions, see release page.

License

Copyright (C) 2021 Vangogiel - Norbert Gogiel

Licensed under the Apache License, Version 2.0