---
title: "Proof of Work"
path: "/contents/resources/python-scripts/proof-of-work"
version: "1.1.0"
author: "Hydrate"
createdAt: "2026-01-27T11:53:54.804Z"
updatedAt: "2026-03-16T18:20:55.149Z"
---

# Proof of Work

A basic implementation of the Proof of Work (PoW) algorithm used as Sybil prevention by [Bitcoin](https://bitcoin.org) and other PoW networks. A deeper comparison between PoW and Proof of Stake (PoS) can be found in our article [**PoW vs PoS: The Next Industrial Revolution**](/blog/pow-vs-pos-the-next-industrial-revolution).

<Columns gap="md" align="start">
<Column>

</Column>
<Column>

</Column>
</Columns>

## **Method & Python Script**

1. $1
2. $1
3. $1
4. $1
5. $1
6. $1
7. $1
8. $1

```python
# v.0.1

from hashlib import sha256
from datetime import datetime

def pow(data, zeros, nonce):
    data = str(data).encode("utf-8")
    zeros = zeros * "0"

    t1 = datetime.now()
    while True:
        combo = data + f"{nonce}".encode("utf-8")
        hash_ = sha256(combo).hexdigest()
        if hash_.startswith(zeros):
            t2 = datetime.now()
            return nonce, hash_, t2-t1
        else:
            nonce += 1

output = pow("hello", 5, 0) # 5 = ~ 1 second
print(output)
```
1. $1
`python3 pow.py`