Skip to main content

A small package which can add HMACs to pickle files for integrity checks upon unpickling

Project description

secure-pickle

The "pickle" package in python enables users to export almost any type of object containing data to an external file. This file can then be simply loaded into memory whenever the need for the object arises, as opposed to regenerating the object each time. The main application of this package is for objects which are computationally expensive to generate, such as machine learning models. This repo contains a python package which streamlines the process of ensuring the integrity of a pickle file by attaching a hash-based message authentication code (HMAC) with it.

Usage

To use this package simply run the command 'pip3 install secure-pickle' and include the line

from securepickling.src.securepickle import securedump, secureload

at the top of your file and then the two included functions will be callable by their name.

The package contains two functions which are based on the Python 'pickle' module:

securedump(obj, file, SECRETKEY)

desc: Writes bytedata of 'obj' and an HMAC generated with 'obj' and 'SECRETKEY' to 'file'

params: obj - Any python object that you wish to write out to a pickle file
        file - A file object which must be in 'wb' mode
        SECRETKEY - A string or bytearray which must be at least 64 bytes to ensure security

returns: nothing

secureload(file, SECRETKEY)

desc: Loads bytedata from 'file' and verifies its integrity using the HMAC in the file and the bytedata and 'SECRETKEY'

params: file - A file object which must be in 'rb' mode
        SECRETKEY - A string or bytearray which will be used to verify the HMAC

returns: the object loaded from pickle file, assuming integrity check passes

Links

https://pypi.org/project/secure-pickle/

https://github.com/Ethan-Dowalter/securepickling

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

secure_pickle-0.0.9.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

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

secure_pickle-0.0.9-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file secure_pickle-0.0.9.tar.gz.

File metadata

  • Download URL: secure_pickle-0.0.9.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for secure_pickle-0.0.9.tar.gz
Algorithm Hash digest
SHA256 778d1f675420903bc86571731fdb4e7d74e5b3f502dd9dd547a0f0d357ecf5c6
MD5 34abf43f7fc984fffb550be30d891c3d
BLAKE2b-256 31020e99e66a71edf5ae24983c153d531b6c5fc11d7897aa935135eacf66fc75

See more details on using hashes here.

File details

Details for the file secure_pickle-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: secure_pickle-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for secure_pickle-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 cb87028d6ca291df33ecdea5cf7fc83f8e28ea5f74f4772289bd698492f5b491
MD5 9c7d0145997ea4c2c95298ccd5b2452f
BLAKE2b-256 8ed27c8f1354ea8fa6fc132c64b8674a24a7d04c8914fa9bff7e725414687ae5

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