Skip to main content

Python Cryptography

Project description

🔐 Python Cryptography

A blazing-fast cryptography library for Python, built on Rust.

Supports an extensive set of post-quantum digital signature algorithms (DSA) and key encapsulation mechanisms (KEM).

⚠️ Disclaimer: This library is intended for educational and research purposes only and is not recommended for production use.

⚡ Features

  • ✅ Dozens of NIST PQC candidates
  • 🦀 Rust core for speed and safety
  • 📦 Easy installation via pip

🧬 Supported Algorithms

💻 Classic

Cipher

  • ChaCha20Poly1305

  • XChaCha20Poly1305

Encoding

  • Base58

Hashing

  • Blake3

  • Keccak

  • Ripemd

Password Hashing

  • Argon2

  • Bcrypt

🛰️ Quantum

🛡️ KEM

  • Bike

  • ClassicMcEliece

  • Hqc

  • Kyber

  • MLKEM

  • NtruPrime

  • FrodoKem

✍️ DSA

  • Cross

  • Dilithium

  • Falcon

  • Mayo

  • MLDSA

  • Sphincs

  • Uov

❔ Examples

DSA Example

from kryptoon.quantum.dsa import Algorithm, KeyPair

# Step 1: Generate a new key pair (secret key and public key) using the MLDSA87 algorithm.
alicesk, alicepk = KeyPair(Algorithm.MLDSA.MLDSA87)

# Step 2: Restore (import) the secret key from its raw bytes.
# This simulates loading a saved secret key from storage.
secretkey = KeyPair(Algorithm.MLDSA.MLDSA87, secretkey=alicesk.secretkey)

# Step 3: Restore (import) the public key from its raw bytes.
# This simulates loading a saved public key from storage.
publickey = KeyPair(Algorithm.MLDSA.MLDSA87, publickey=alicepk.publickey)

# --- Alternative: Combined Key Import ---
# You can also restore both keys at once using a single call.
# This is useful when both the secret and public keys are available together.
secretkey, publickey = KeyPair(
    Algorithm.MLDSA.MLDSA87,
    secretkey=alicesk.secretkey,
    publickey=alicepk.publickey
)

# Step 4: Prepare the message to be signed (convert string to bytes).
message = "Hello".encode()

# Step 5: Sign the message using the secret key.
signature = secretkey.sign(message=message)

# Step 6: Verify the signature using the public key.
valid = publickey.verify(signature=signature, message=message)

# Step 7: Ensure that the signature is valid.
# If the verification fails, the program will raise an error.
assert valid, "Signature verification failed!"

# Step 8: Display the original message (decoded back to string).
print(f"Message:   [{message.decode()}]")

# Display the last 64 hex characters
print(f"Signature: [{signature.hex()[-64:]}]")
print(f"SecretKey: [{alicesk.secretkey.hex()[-64:]}]")
print(f"PublicKey: [{alicepk.publickey.hex()[-64:]}]")

KEM Example

from kryptoon.quantum.kem import Algorithm, KeyPair

# Step 1: Generate key pairs for Alice and Bob using MLKEM1024 algorithm
alicesk, alicepk = KeyPair(Algorithm.MLKEM.MLKEM1024)
_bobsk, _bobpk = KeyPair(Algorithm.MLKEM.MLKEM1024)

# --- Key Export ---
# Export Alice's keys as bytes (simulate saving keys)
alice_secret_bytes = alicesk.secretkey
alice_public_bytes = alicepk.publickey

# Export Bob's keys as bytes (simulate saving keys)
bob_secret_bytes = _bobsk.secretkey
bob_public_bytes = _bobpk.publickey

# --- Key Import ---
# Re-import Alice's keys from bytes
alicesk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, secretkey=alice_secret_bytes)
alicepk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, publickey=alice_public_bytes)

# Re-import Bob's keys from bytes
bobsk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, secretkey=bob_secret_bytes)
bobpk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, publickey=bob_public_bytes)

# Step 2: Bob encapsulates a shared secret using Alice's public key
bobss, bobct = alicepk_restored.encapsulate()

# Step 3: Alice decapsulates the ciphertext using her secret key to recover the shared secret
alicess = alicesk_restored.decapsulate(bobct)

# Step 4: Verify that both shared secrets match
assert alicess == bobss, "Shared secrets do not match!"

# Step 5: Print results
print(f"Alice's Shared Secret: [{alicess.hex()}]")
print(f"Bob's   Shared Secret: [{bobss.hex()}]")

# Display the last 64 hex characters
print(f"SecretKey:             [{alicesk_restored.secretkey.hex()[-64:]}]")
print(f"PublicKey:             [{alicepk_restored.publickey.hex()[-64:]}]")

📦 Install

pip install kryptoon

🥳 Enjoy!

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

kryptoon-2026.1.2.tar.gz (16.8 kB view details)

Uploaded Source

Built Distributions

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

kryptoon-2026.1.2-cp314-cp314-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.14Windows x86-64

kryptoon-2026.1.2-cp314-cp314-manylinux_2_38_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ x86-64

kryptoon-2026.1.2-cp314-cp314-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

kryptoon-2026.1.2-cp313-cp313-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.13Windows x86-64

kryptoon-2026.1.2-cp313-cp313-manylinux_2_38_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ x86-64

kryptoon-2026.1.2-cp313-cp313-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kryptoon-2026.1.2-cp312-cp312-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.12Windows x86-64

kryptoon-2026.1.2-cp312-cp312-manylinux_2_38_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

kryptoon-2026.1.2-cp312-cp312-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kryptoon-2026.1.2-cp311-cp311-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.11Windows x86-64

kryptoon-2026.1.2-cp311-cp311-manylinux_2_38_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.38+ x86-64

kryptoon-2026.1.2-cp311-cp311-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kryptoon-2026.1.2-cp310-cp310-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.10Windows x86-64

kryptoon-2026.1.2-cp310-cp310-manylinux_2_38_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.38+ x86-64

kryptoon-2026.1.2-cp310-cp310-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file kryptoon-2026.1.2.tar.gz.

File metadata

  • Download URL: kryptoon-2026.1.2.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for kryptoon-2026.1.2.tar.gz
Algorithm Hash digest
SHA256 21c7b1a4d947b84e06099f0a02776b8f4e76b9f8285ae0b60305d57d44ef8cfb
MD5 30a48ae5dc1bdb2d757e545edb6be704
BLAKE2b-256 8426b17747593abc73a0f607540417c58dd36b43635837c7e7b00e125175f7a5

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 7d6c94f8779f5e235809f141003035429c57c5fdadb84aa09acc82df1e2e382f
MD5 1038a27b454d7a87b576b2257b8b7196
BLAKE2b-256 18e1260dabb74b9f4a5d6135ae97afb0c67d334612243cee41a153e95b665b2e

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp314-cp314-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 08845bdef8585d10dbda440a6a61f5e233b97e1833163f1b24b0ffd382246237
MD5 42e49f253e572470b0bf8767c1623079
BLAKE2b-256 336d243a3d33a9d16504b4548b80ea06f5588cf530d783c1de03d42f8f1b6d36

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6800b171378ef9dece5a36cac7cff8374d1bbe8e71d527324497afe020a09868
MD5 7eb2aeebf8ac5182999038f7fbd981b9
BLAKE2b-256 4c07f0ff7515c0f8ade03f9f25e7b7421a919c4898db1b4797e5da454b960393

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3664d4b4dbf388ad41f01e18ac77f56ca9f36ad19b54f473b0a4525c13b0ac08
MD5 ec2c26aa5a7e58b6de309822a9583ddc
BLAKE2b-256 62bff57957e6ad0ec072dfec62b75f426e5d6d3994bf1c2c19cbc37b466dbb87

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp313-cp313-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 2d6b6d84d4aba7e767fa3394cbc8768173c0e0c3a0a8ffad6ec5c57e0a51a1cf
MD5 328f6783b10b0df5fc9a1331ebcf8c9f
BLAKE2b-256 8bf9f552219fbc660b409f70269064df52fe678890d7c911f0f38699f1468936

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e28ffcd66237c46651f8d1e0ae70b0d469ae8d5fe6175da19885ab015208e6a
MD5 bc1b07f28633353afbcc86f20d267750
BLAKE2b-256 77286c35cd4ceb485db9aeef353da2850b3ec8c2e2d500889c697332a955878c

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4444245770e1ed11e1cbe2b2cafff1e31128d8c0419378007de38a8c23c4b9d6
MD5 ee066cf002ae849580342f9878d11ebc
BLAKE2b-256 07729fa934a45e3f6a5a342f94560da0bba619af9b40fa3630482edca94784b4

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 514424e01d5900403f3e9cd0adcc04300caac55b1594401198af20dfd8391d00
MD5 aa7f35a915a89cffabd5ac8ab2eb5c16
BLAKE2b-256 8eb7e8785e15d38937c1baab0571c4c50d2dcfbcbbb16d096e0bfb27c8610486

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3266bfe59fad4c531c55bb7378d47eb08fde0d69ed19636226ba93acb03b469b
MD5 7b6e74f4db856290c130048a9e669092
BLAKE2b-256 a6357c378462391fbcdf0460c853e86c5966c42fc5e9be864815bde81228c4fc

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 440e3aa956b740181613647c89b882cff498b37ec37ed113dfcc9a1e47ebb94a
MD5 07cbb1a01016198807ab86e87e68a55d
BLAKE2b-256 8a8370975c3b1594b2b444dbd07b928de027fd015169b4dce8e8e6a9b102027a

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp311-cp311-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 3b40746c7556988b9fa245d6622b475c751386366a428a93961a053ce546c8a1
MD5 c61b26fabc6c92e95c302559c66c3b40
BLAKE2b-256 432594bc90d4af07c21c7965110afc27ccd9d5fb9ca76dd6cb3eff24085691a9

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7290b3bddda3462a66618d4352fe4b0be133d6f8748d52423c60a73776e6e771
MD5 0ae6faad1d224b7ca489f4a9e3b34049
BLAKE2b-256 c2ff114e922b790d33e205db776d2422fbb3d7263581acd770bdd6a57169b14f

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5daff8b0652be096c0894d723490da40a17b2195c0b5dd3e3fedb52e4f488969
MD5 bf587f0d29916694acbf0be04cee09ce
BLAKE2b-256 a1a8de55106c40ed16c9ac97f5e85d6284935d8424b5542e445d6ba2fff6aef2

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp310-cp310-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 40eaf45b2474cf790de57a52c3cb508af3fa65c8db223d582328a59cfb830227
MD5 b7e0911464a719083efc8839ebed3c3c
BLAKE2b-256 75f7e711e612ebb01cf68ad9e39eabe0121c1317b08c7240cdabbe0afb9b06e2

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 decd73360dea3642e7f3d8b7912eb3388edf219f29ccd7032d5e97e8da2c47ec
MD5 1192fed209132b125752813acb72fd2b
BLAKE2b-256 229452ff093d46a256189723197a672531e092ac3f1e451a71eb4da4e4212d9a

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