/hkid-validator

Hong Kong ID number validator

Primary LanguageCMIT LicenseMIT

HKID Validator

The algorithm is based on https://computerterminal.blogspot.com/2005/11/hkid-calculation.html.

Algorithm

Supports multiple languages, see below.

All the libraries are case-insensitive. “a123456a” and “A123456A” are no different.

Go

At source root.

go get github.com/drshapeless/hkid-validator/go/hkidvalidator
import "github.com/drshapeless/hkid-validator/go/hkidvalidator"

// Usage:
// checkHKID(string)
// Returns True or False

hkidvalidator.CheckHKID("A1234567")						// Returns False

C

Compile with the source file, hkidvalidator.c and hkidvalidator.h.

#include "hkidvalidator.h"

/* Usage */
/* checkHKID(char *) */
/* Returns 1 or 0 */
/* 1 is true */

checkHKID("A1234567")           /* Returns 0 */

Python

Copy hkidvalidator.py to the project directory.

import hkidvalidator

hkidvalidator.checkHKID("A1234567") # Returns False

JavaScript

Copy hkidvalidator.js to the project directory.

const v = require("./hkidvalidator.js")

v.checkHKID("A1234567")         // Returns false