Skip to main content

A simple proof of work using SHA-256 hashes

Project description

Proof of work

A simple Proof Of Work module made with python

POW ALGORITHM

The algorythm used in this module is very simple: The inputs are an initial SHA-256 hash (that could be the last proof of work hash, like in bitcoin system) and a difficult in number of zeroes. That means the number of zeroes that the resulting hash must have at it's begining.

Starting with those two arguments, the script now makes a new random hash. That's the proof of work. This new hash has to meet a condition:

  1. The new hash is attached to the initial hash
  2. The script now converts those two joint hashes (initial + new) into another hash. (Resulting hash)
  3. If the resulting hash begins with the specified number of zeroes, the proof of work is valid.
  4. The information returned is: (proof_of_work_hash, resulting_hash, number_of_attempts)

Notice that the resulting hash may have more zeroes than the specified. The difficult is a minimum.

For curious people: What is a proof of work?

Other methods

proof_of_work() is not the only method contained in this module. Here's an explanation of some others:

  • random_hash(): Returns a random SHA-256 hash.
  • make_hash(string): Converts a string into a SHA-256 hash.

How to use it

From pip: pip install powpy From github repository: Download and run setup.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

powpy-0.1.1.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

powpy-0.1.1-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file powpy-0.1.1.tar.gz.

File metadata

  • Download URL: powpy-0.1.1.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for powpy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f9f629aa26701ba78d654064cb360ad22892fad6c1eadcfc92cffad13945d538
MD5 f14f25e2bd29906edb3ccf3c9f94fe21
BLAKE2b-256 9dc92f1655f5ac64f58232b7acfc4df3607ef8682871aa0573fcf533c386da73

See more details on using hashes here.

File details

Details for the file powpy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: powpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for powpy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a7dd54d9e1b1d88be7767b500c6efb567b0e6d4b385a079bac5d89afbebd78c
MD5 f06e81c1d71089648aa8b15835aa17fa
BLAKE2b-256 13626587e82bd3823fd4f9b752cafe04064ef003bd65cfc01588344b802768b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page