The ideas goes back to a concept called HashCash which was meant as a deterrent to spam. When an e-mail is sent another value must be sent with it. When you take this value, add it to the message, and then take a cryptographic hash you must have a hash value with certain characteristics.
For instance, take a cryptographic hash using the SHA256 hashing algorithm of the term “message” (without quotes) and you get:
Now if the rules say you must have a hash that starts with a zero you can start adding stuff until you get a hash that works:
After going through the numbers sequentially 51 was the first one that worked. As long as “51” is sent along with the message the receiver can quickly verify it meets the requirements by performing the hash and accept the message. The added portion, in this case”51,” is called a “nonce.”
Bitcoin mining works by compiling the transactions, the value that depends on all previous blocks, and then finding a “nonce” that meets the criteria.
As more people mine Bitcoin the problem gets harder and harder so that a block is created every 10 minutes on average. This is done by increasing the number of zeros. So a has that starts with “0…” easy, one that starts with “00…” is a bit harder and so forth.