Skip to main content

Implementation of random checksum protocol

Project description

RCP - Random Checksum Protocol

How to implement

  • Have a dict
  • Sort alphanumerical
  • Concat its keys and values: key1value1key2value2...
  • Append shared secret
  • Append current utc timestamp
  • Optional: Add a salt: saltkey1value1...
  • Hash with SHA512
  • Represent the hash as hex

How to use

Get checksum

from rc_protocol import get_checksum

SHARED_SECRET = "s3cr3t_p@ssw0rd"

my_dict = {
    "key1": "value1",
    "key2": "value2"
}

my_dict["checksum"] = get_checksum(my_dict, SHARED_SECRET)

Validate checksum

from rc_protocol import validate_checksum

SHARED_SECRET = "s3cr3t_p@ssw0rd"

my_dict = {
    "key1": "value1",
    "key2": "value2",
    "checksum": "d0690e3c924e18bad866e2867698be75f64bdc6e809b76ffedb5c5095c9fbe15d36636b2df1fc47d2a3f348aea272ffc2fed4dc8ee08e0d13631ef646e1648c4"
}

if validate_checksum(my_dict, SHARED_SECRET):
    do_random_things()
else:
    print("You shall not pass.")

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

rc_protocol-0.0.1.tar.gz (1.9 kB view details)

Uploaded Source

File details

Details for the file rc_protocol-0.0.1.tar.gz.

File metadata

  • Download URL: rc_protocol-0.0.1.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for rc_protocol-0.0.1.tar.gz
Algorithm Hash digest
SHA256 230760e816f96e4ee71df875df17e5c2a6630047c466943309be4d3e5e104df2
MD5 20ae6d4d7dcd101c83188039f8f13d68
BLAKE2b-256 bd4cf0121e8420ab8d3d3957407b3aa925f37176e2b3bda90fe47f9b854b17b5

See more details on using hashes here.

Supported by

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