DataSafe - Utilities for data encryption / decryption
Table of contents
Installation
pip install datasafe
Docker
git clone --depth 1 https://github.com/StephenRicher/datasafe.git
cd datasafe/
docker build -t datasafe .
docker run datasafe --help
Command-line
Encrypt
datasafe encrypt data.csv > data.encrypted
Decrypt
datasafe decrypt data.encrypted > data.decrypted.csv
Python
datasafe can be imported as a python module to encrypt and decrypt files.
Pandas
If a Pandas DataFrame is provided to datasafe.encrypt then it will be encrypted in .parquet format.
Following decryption, an in-memory buffer is returned which should be passed to pd.read_parquet to recover the dataframe and datatypes.
import pandas as pd
from datasafe import encrypt, decrypt
df = pd.DataFrame({
'A': [1, 2, 3],
'B': ['dog', 'cat', 'bat']
})
encrypt(df, 'df-encrypted.pq')
df = pd.read_parquet(decrypt('df-encrypted.pq'))
Files
The command line functionality can also be achieved within Python.
In addition the datasafe.decrypt function returns an in-memory buffer which can be read directly.
Encrypt and write encrypted data to file
import pandas as pd
from datasafe import encrypt, decrypt
with open('data.encrypted', 'wb') as fh:
fh.write(encrypt('data.csv'))
Decrypt and write decrypted data to file
with open('data.decrypted.csv', 'w') as fh:
fh.write(decrypt('data.encrypted').getvalue())
Decrypt and read in-memory buffer to Pandas
df = pd.read_csv(decrypt('data.encrypted'))
License
Distributed under the MIT License. See LICENSE for more information.
Contact
If you have any other questions please contact the author Stephen Richer at stephen.richer@proton.me
Metadata
Release files for datasafe 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| datasafe-0.1.0.tar.gz | 5.1 kB | Without provenance | Details for datasafe-0.1.0.tar.gz |
Release files / datasafe-0.1.0.tar.gz
| Download URL | datasafe-0.1.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f44d687a9572745c29764ba2c6a33c1b7585fa201260f4e50521162db55abb7
|
|
BLAKE2b-256 checksum How to use checksums |
2bc92442ba905208bf0992851792db6d3fa8589f8bf88142047b1c4a9384c05e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.7
|
Security for datasafe 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.