DIDWW Encrypt Python 3 SDK
This is Python 3 module and utility to encrypt file for DIDWW API 3.
File encrypted with mode sandbox could be uploaded to POST https://sandbox-api.didww.com/v3/encrypted_files.
File encrypted with mode production could be uploaded to POST https://api.didww.com/v3/encrypted_files.
see DIDWW Documentation for details.
Requirements
Python >=3.6
Dependencies
Install
pip install didww_encrypt
Usage
Inside python
from didww_encrypt import Encrypt, MODE_PRODUCTION
with open("doc.pdf", mode="rb") as f:
data = f.read()
enc = Encrypt.new(MODE_PRODUCTION)
enc_data = enc.encrypt(data)
enc_filename = "doc.pdf.enc"
with open(enc_filename, mode="wb") as f:
f.write(enc_data)
print(f"encrypted file saved: {enc_filename}")
print(f"fingerprint: {enc.fingerprint}")
Shell
usage: didww_encrypt [-h] [-i [INPUT]] [-o [OUTPUT]] [-f] (-m [{sandbox,production}] | -u [URI])
Encrypt file for DIDWW API 3
optional arguments:
-h, --help show this help message and exit
-i [INPUT], --input [INPUT]
use input pipe when not passed
-o [OUTPUT], --output [OUTPUT]
use output pipe when not passed
-f, --fingerprint return fingerprint for public keys
-m [{sandbox,production}], --mode [{sandbox,production}]
which DIDWW server use for public keys fetching
-u [URI], --uri [URI]
custom URI for public keys fetching
You can pass input and output files as params
$ didww_encrypt -i ./doc.pdf -o ./doc.pdf.enc -m sandbox
Or using pipe
$ cat ./doc.pdf | didww_encrypt -m production > ./doc.pdf.enc
Also script could be run via python -m
$ python -m didww_encrypt -i ./doc.pdf -o ./doc.pdf.enc -m production
$ cat ./doc.pdf | python -m didww_encrypt -m sandbox > ./doc.pdf.enc
To print fingerprint use -f option instead of -i
$ didww_encrypt -f -mode sandbox
c74684d7863639169c21c4d04747f8d6fa05cfe3:::7c56fd5d2e1f2ada18765d936e74712037aea7eb
Or you can save it to a file
$ didww_encrypt -f -mode sandbox -o fingerprint.txt
Keep in mind that shell script returns fingerprint with newline which should be omitted when send it to /v3/encrypted_files.
Additional information
both shell script and module function Encrypt.new respects http_proxy env variable when fetching public keys.
http_proxy="http://myproxy.example.com:1234" didww_encrypt -m sandbox
Development
Install dependencies
pip install -r requirements.txt
pip install -r tests/requirements.txt
Run tests
python -m unittest -v
Run tests with coverage
coverage run -m unittest -v
Lint with flake8
flake8 . --count --show-source --statistics
Fix code format with Black
black .
Metadata
Release files for didww-encrypt 1.0.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 |
|---|---|---|---|---|
| didww_encrypt-1.0.0.tar.gz | 6.2 kB | Without provenance | Details for didww_encrypt-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| didww_encrypt-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for didww_encrypt-1.0.0-py3-none-any.whl |
Total release size: 13.1 kB
Release files / didww_encrypt-1.0.0.tar.gz
| Download URL | didww_encrypt-1.0.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eefe5fd6eff8ce6150378d5149647abab02a11bcb6d1d6a1ac15a290c2db9516
|
|
BLAKE2b-256 checksum How to use checksums |
556d587a699921e21a42d37cc822410160be4ad5de8787789c03924a531eb598
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
|
Release files / didww_encrypt-1.0.0-py3-none-any.whl
| Download URL | didww_encrypt-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e9deef3fddc9f34e99fa4575659ac1de5564a85278358a131de0be87122127c
|
|
BLAKE2b-256 checksum How to use checksums |
d76228cd20f32f8e9dfa9129a4ababc6a4acd035735b40671503198701388c7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
|
Security for didww-encrypt 1.0.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.