UNPKG

thai-citizenid-gen

Version:

A library for generating valid Thai Citizen IDs and mock Thai personal data. Updated to correctly follow the ID generation algorithm and resolve security vulnerabilities in dependencies.

10 lines (9 loc) 398 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateThaiID = generateThaiID; function generateThaiID() { const digits = Array.from({ length: 12 }, () => Math.floor(Math.random() * 10)); const sum = digits.reduce((acc, digit, i) => acc + digit * (13 - i), 0); const checkDigit = (11 - (sum % 11)) % 10; return digits.join('') + checkDigit; }