Skip to main content

Implementation of random checksum protocol

Project description

RCP - Random Checksum Protocol

RCP's main use case is providing a checksum to validate requests between HTTP Servers. Therefore each server has a shared secret to which all the others have to have access to.

How to implement

  • Put all your data from your POST or GET Request in a dictionary
  • Sort the dictionary alphanumerical by its keys.
  • Concat its values to the respective key and join them: key1value1key2value2...
  • Append the shared secret of your target
  • Append current utc timestamp (unix epoch - just seconds)
  • Optional: Add a salt (this may be the methods endpoint): saltkey1value1...
  • Hash with SHA512
  • Represent the hash as hex string (lowercase)
  • The endpoint you're trying to reach should have the key stated, it expects the checksum to be in. In the reference implementation this defaults to checksum.

Watch out As this protocol heavily depends on retrieving the correct time, it may be required to enable NTP on your servers.

How to use the reference implementation

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.5.tar.gz (9.9 kB view details)

Uploaded Source

File details

Details for the file rc-protocol-0.0.5.tar.gz.

File metadata

  • Download URL: rc-protocol-0.0.5.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for rc-protocol-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a912d92ad128e05dab60efad47c15377b87646be313306923b197a545a013629
MD5 a9e8949fe704fe16bc2dfe0d62f90c81
BLAKE2b-256 0e84073e134f99dc91ad697a775b2e4c60d4ca4c7fb4a846620d3625eba0ed62

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