{"id":15551518,"url":"https://github.com/decadenza/luhn","last_synced_at":"2026-03-13T10:32:20.724Z","repository":{"id":239797713,"uuid":"800134786","full_name":"decadenza/luhn","owner":"decadenza","description":"Luhn Mod N algorithm as a Go module","archived":false,"fork":false,"pushed_at":"2025-01-19T18:37:31.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-19T20:09:17.107Z","etag":null,"topics":["checksum","luhn-algorithm","validation"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/decadenza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-13T19:07:36.000Z","updated_at":"2025-01-19T18:37:33.000Z","dependencies_parsed_at":"2024-05-15T12:35:56.538Z","dependency_job_id":"8b702247-0b84-45e2-a10a-77f9b3506fe8","html_url":"https://github.com/decadenza/luhn","commit_stats":null,"previous_names":["decadenza/luhn"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/decadenza/luhn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decadenza%2Fluhn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decadenza%2Fluhn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decadenza%2Fluhn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decadenza%2Fluhn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decadenza","download_url":"https://codeload.github.com/decadenza/luhn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decadenza%2Fluhn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30465423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T06:34:02.089Z","status":"ssl_error","status_checked_at":"2026-03-13T06:33:49.182Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checksum","luhn-algorithm","validation"],"created_at":"2024-10-02T14:05:16.901Z","updated_at":"2026-03-13T10:32:20.692Z","avatar_url":"https://github.com/decadenza.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Luhn algorithm\nImplementation of Luhn Mod N algorithm for *any base (modulus)* divisible by 2 in the range from 2 to 36.\nMost used configurations are:\n- Luhn Mod 10\n- Luhn Mod 16 (hexadecimal)\n- Luhn Mod 36 (all 0-9 and A-Z characters)\n\n## Character mapping\nThe character mapping is based on the standard [strconv](https://pkg.go.dev/strconv) package.\nLetter `A` is mapped to 10 and all other letters are mapped subsequentially, up to letter `Z` which is mapped to 36.\nThe expected input is a string where each character is treated independently.\n\n## Pros and cons\nThe Luhn algorithm will detect all single-digit errors, as well as almost all transpositions of adjacent digits. It will not, however, detect transposition of the two-digit sequence _(base-1)_-0 to 0-_(base-1)_ (or vice versa), e.g. swapping 09 with 90 in Mod 10. \nIt will detect most of the possible twin errors, but not all of them (e.g. in Mod 10 it will not detect 22 ↔ 55, 33 ↔ 66 or 44 ↔ 77). \n\n## Install and import\nInstall with:\n```\ngo get -u github.com/decadenza/luhn\n```\nImport as:\n```\nimport \"github.com/decadenza/luhn\"\n```\n\n## Basic example\n```\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/decadenza/luhn\"\n)\n\nfunc main() {\n    base := 16\n    myPayload := \"14FAD\"\n\n    luhn, err := luhn.New(base)\n    if err != nil {\n        panic(err)\n    }\n\n    // Generate and concatenate checksum.\n    checksum, err := luhn.GetChecksum(myPayload)\n    if err != nil {\n        panic(err)\n    }\n    fullCode := myPayload + checksum\n\n    // Check its validity.\n    valid := luhn.IsValid(fullCode)\n    fmt.Printf(\"%s is valid? %t\\n\", fullCode, valid)\n\n    // A mistyping will not be valid.\n    wrongCode := \"1AFAD\" + checksum\n    valid = luhn.IsValid(wrongCode)\n    fmt.Printf(\"%s is valid? %t\\n\", wrongCode, valid)\n}\n```\n\nRefer to test files for further examples.\n\n\n## References\n- [Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm)\n- [Luhn mod N algorithm](https://en.wikipedia.org/wiki/Luhn_mod_N_algorithm)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecadenza%2Fluhn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecadenza%2Fluhn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecadenza%2Fluhn/lists"}