SShortSingh.
Back to feed

Your Card Number's Typo Check Is 70 Years Old and Still Works

0
·5 views

Every card number typed into a checkout form is screened by the Luhn algorithm, a arithmetic check developed decades before modern computers existed. IBM scientist Hans Peter Luhn created it in the 1950s to catch transcription errors in identification numbers, adding a check digit computed from the preceding digits. The same test still validates card numbers, IMEI numbers on phones, and several national ID numbers, running offline in milliseconds. Its method doubles every second digit from the right, subtracts 9 where results exceed 9, and checks whether the total is a multiple of 10. The approach catches nearly all single-digit errors and most adjacent transpositions.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

A Timed-Out RPC Call Can Still Send Two OTPs, Here's Why

A single timeout during a remote login-code request can leave the caller unsure whether the operation failed, because the server may have accepted the message before the response was lost. The article follows one call from a Go authentication service to a Java notification service, illustrating how a generated client stub turns a method call into a network exchange. It explains that Protocol Buffers encode the request for a shared wire format and that gRPC transmits it over HTTP/2. Because a failed call does not always mean a failed operation, blind retries can cause users to receive duplicate codes. The piece concludes by describing how to make such retries safe.

0
ProgrammingDEV Community ·

Why Pre-Tax and Post-Tax Paycheck Deductions Are Applied in Different Order

A developer building a paycheck calculator found that the sequence of deductions affects take-home pay as much as their amounts. Pre-tax deductions such as traditional 401(k) contributions and Section 125 health premiums lower the wages used for income tax, while post-tax items like Roth 401(k) contributions are taken after taxes are calculated. A traditional 401(k) reduces federal income tax but not Social Security or Medicare, so a calculator must track income-tax wages and FICA wages separately. The article illustrates this with a $1,000 weekly paycheck, showing how each deduction changes the figures used for withholding. The author concludes that every deduction must be classified by which wage figures it reduces to produce accurate estimates.

0
ProgrammingDEV Community ·

How countdown widgets stay accurate on iOS and Android

Home-screen widgets are rendered by the operating system on its own schedule, so updating every second is not a workable approach. On iOS, WidgetKit uses a timeline of entries, with date-style text that the system keeps ticking live and new entries only when meaningful changes occur. On Android, the minimum widget update interval of 30 minutes is too coarse for minute-level changes, so developers can use a Chronometer for a live countdown or schedule a refresh shortly after midnight for day counts. The article stresses storing the target date and time with its time zone rather than a running counter, since restored widgets would otherwise drift. The author, who builds a vacation countdown app, recommends starting with these built-in mechanisms before relying on background refresh.

0
ProgrammingDEV Community ·

How to Turn a Single Photo Into a Shareable AI Video Clip

The guide explains that people searching for AI video effects usually want a short, ready-made motion from a still photo rather than a full video built from a detailed prompt. It distinguishes one-tap effects, which apply a named motion recipe to an uploaded picture, from broader generative tools that accept text or image prompts and require more direction. The workflow advises naming the goal first, choosing a sharp, well-lit source image whose subject suits the chosen motion, and checking the credit cost before generating. It also recommends reviewing the full clip for artifacts such as face drift or collapsing motion, changing only one variable at a time when fixing problems, and selecting a vertical or square format based on how the subject is framed.