This is a Python interface to the CryptoSys PKI Pro library.
CryptoSys PKI Pro is a library to carry out public key cryptography using RSA and ECDSA. You can generate and manage X.509 certificates, PKCS#8/PKCS#12 private keys and CMS/PKCS#7 objects. It includes all required supporting cryptographic utilities.
CryptoSys PKI Pro v23.2 or above must be installed on your system. This is available from
To use in Python’s REPL
>>> from cryptosyspki import *
>>> Gen.version() # "hello world!" for CryptoSys PKI
220100
>>> Hash.hex_from_data(b'abc') # compute SHA-1 hash in hex of 'abc' as bytes
'a9993e364706816aba3e25717850c26c9cd0d89d'
>>> Hash.hex_from_string('abc', Hash.Alg.SHA256) # same but over a string and using SHA-256
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
>>> h = Hash.data(b'abc') # h is a byte array (bytes->bytes)
>>> print(Cnv.tohex(h)) # display the byte array in hex
A9993E364706816ABA3E25717850C26C9CD0D89D
If you don’t like import * and find cryptosyspki a bit long to type each time, try
>>> import cryptosyspki as pki
>>> pki.Gen.version() # Underlying core PKI dll
230200
>>> pki.__version__ # cryptosyspki.py package
'23.20.00.0000'
Examples
There is a series of tests in test_pki.py (source). You should find an example there of what you want to do.
These tests require a subdirectory work in the same folder which must contain all the required test files. A spare set of these test files is available separately in pkiPythonTestFiles.zip
test
| test_pki.py
|
\---work
| <...all required test files>
|
\---tmp.XXXXXXXX
<..temporary files...>
The test function creates a new temporary subdirectory each time, which is deleted automatically. If you want to keep this temp folder for debugging, then add the argument nodelete on the command line.
This structure is already set up in the distribution file, so unzip the file cryptosyspki-x.x.x.zip and open a command-line prompt in the test subdirectory. You can do any of the following.
python test_pki.py
py.test -v
Open the file test_pki.py using IDLE and select Run > Run Module (F5).
We’ve tested this using the Python 3.12.0 interpreter and IDLE, PyCharm 2023.2.3, and py.test 7.4.2.
Contact
For more information or to make suggestions, please contact us at https://cryptosys.net/contact/
Release files for cryptosyspki 23.2.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 | |
|---|---|---|---|
| cryptosyspki-23.2.0.tar.gz | 258.5 kB | Details |
Release files / cryptosyspki-23.2.0.tar.gz
| Download URL | cryptosyspki-23.2.0.tar.gz |
|---|---|
| Size | 258.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a62605edc7be08604e9debe81060a8d80e8a3a01e42c2b425027e9feae870bf4
|
|
BLAKE2b-256 checksum How to use checksums |
9df3c686e2113bdad4ed198151ae1d961127c62b356e11e8c461f268f5ca393f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.0
|