Home  Contents

magstripe.decode

Magstripe Core4 Lua Event System

SYNOPSIS

data, resultcode = magstripe.decode(tracknr, rawdata)

DESCRIPTION

This function takes the raw magnetic stripe bits rawdata and tries to decode them according to the ISO standard encoding for track tracknr.

If the trackdata is partially garbled, the function will still provide the data that could be decoded properly. In case of garbled data however, the LRC checksum cannot be checked.

When using swipe or insertion readers, it is a good idea to allow the user to swipe the card in any direction. This can be accomplished by trying to decode the data forward and reverse using string.bitrevert().

RETURN VALUE

Returns two values: data is a string with the decoded data, including the start, end and checksum characters. The second value, resultcode indicates how sucessful the decode was.

resultcode Description
0 Decode was successful
20 No start character seen
21 No end character seen
23 LRC checksum incorrect
24 Parity error

On error, the value data contains all characters that could be decoded up until the error position.

SEE ALSO