From 7297fe9805c2ba8994a64adf22d14fafa745e4d2 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 9 Oct 2023 09:52:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D0=B0=D1=8F=20=D1=84=D1=83?= =?UTF-8?q?=D0=BD=D0=BA=D1=86=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PoW.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 PoW.py diff --git a/PoW.py b/PoW.py new file mode 100644 index 0000000..deb573d --- /dev/null +++ b/PoW.py @@ -0,0 +1,13 @@ +import hashlib + +def check(data, proof, complexity=1, f=hashlib.sha256): + zeros="0"*complexity + hash=f(data+proof) + hashdata=hash.hexdigest() + b=0 + for a in hashdata: + if a=="0": + b+=1 + else: + break + return b>=complexity