Menu

I built a scratch-card scanner. The hard part wasn't reading the digits.
πŸ“°

I built a scratch-card scanner. The hard part wasn't reading the digits.

DEV Community: iosΒ·Tafadzwa Alexander RazaroΒ·3 days ago
#zAkna9Gl
#devtoios#devto#dev#card#four
Reading 0:00
15s threshold

In Zimbabwe you buy airtime on a scratch card. You scratch off the foil, and underneath is a 17-digit PIN. Then you open your dialer and type *121* followed by all seventeen digits, followed by # .

If you mistype one digit, the network rejects it and you try again. If you mistype it twice you start to wonder whether you're reading a 5 or a 6 through a scratched-up panel in bad light. People do this several times a week.

So: point a camera at it, read the digits, build the string. A weekend project.

It was not a weekend project, and almost none of the difficulty was in the OCR.

First instinct: validate the PIN

Before you send a PIN anywhere, you'd like to know it's plausible. Credit card numbers have the Luhn check digit. ISBNs have a weighted modulus. IMEIs use Luhn too. If airtime PINs carried anything similar, a misread would be caught instantly on the device, before a wasted attempt.

I had four real Econet PINs, from four real cards I'd bought.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.