The basic idea is: The client has to create a hash that satisfies a certain condition: Like the first n-digits must be 0, or maybe &quot;the last bytes (when interpreted as a single 32 number) must be larger than x&quot;.<p>So the client does this:<p><pre><code>    from itertools import count
    import hashlib

    for i in count():
        h = hashlib.md5(&quot;some-nonce:%d&quot; % i).hexdigest()
        if h.startswith(&quot;000000&quot;):
            print i
            break
</code></pre>
The value &quot;some-nonce&quot; is provided by the server. It also provides the difficulty by saying: I need you to find i which generates a hash that starts with 6 zeros.<p>So the client calculates hashes for a while, and then submits the value 2652076 to the server. The server can the trivially check if the client did its work correctly:<p><pre><code>    $ echo -en &quot;some-nonce:2652076&quot; | md5sum
    00000066adb2fb37a8460da553721c39 # ok, the first 6 digits are 0
</code></pre>
The server can simply increase the difficulty by requiring the client to return more leading zeros. Or, if it should be more finegrained, a value below a certain threshold.