How do I check the checksum of a Bitcoin address? I'm working on a Bitcoin ATM. We want to detect addresses that are entered incorrectly.

There's a checksum on Bitcoin addresses - but how can we check it?
The way Bitcoin checks a public address is using what is called Base58Check. While the Bitcoin Wiki covers Base58Check, I'll outline how it works in both abstract and technical terms.



The whole idea of Base58Check is to prevent invalid addresses. This is done by adding digits to the start (00) and end of the Base58 value (4 bytes of double SHA256 hash). 


Add 00 to the start of Base58 value ie 00 + BASE58 ==> 00BASE58
Checksum = 1st 8 digits from SHA256(SHA256(00BASE58))


BASE58Check = (00)(BASE58_SHA256RIPEMD160_HEXADECIMAL_VALUE)(CHECKSUM) (parenthesis for visualisation only, all other data is correct in size, ie CHECKSUM = 8 chars)

The best way to visualize all this is with The Piachu's App