UNPKG

wiegand-encoder

Version:

Encode and decode 26, 34, or 38 bit Wiegand protocol credentials

14 lines (13 loc) 696 B
/** * Decode a Wiegand protocol message into a card number and facility code, after validating parity bits * @param {string} wiegand - Wiegand message * @param {number} [cardNumberLength] - How many bits the card number should be * @param {number} [facilityCodeLength] - How many bits the facility code should be * @param {boolean=true} [validateParity] - Whether to validate parity bits on the message or not * @throws * @returns {{cardNumber: string, facilityCode: string}} */ export default function decode(string: string, cardNumberLength?: number | undefined, facilityCodeLength?: number | undefined, validateParity?: boolean): { cardNumber: number; facilityCode: number; };