Skip to main content

Key Encryption Key

Project description

KEK

Python License

Installation

To install KEK:

pip install gnukek

Usage

Generating a Key Pair

from gnukek import KeyPair

key_pair = KeyPair.generate(key_size=2048)

Serializing Keys

private_key = key_pair.serialize(password=b"your_password")
public_key = key_pair.public_key.serialize()

Loading Keys

loaded_key_pair = KeyPair.load(private_key, password=b"your_password")
loaded_public_key = PublicKey.load(public_key)

Encrypting and Decrypting Messages

message = b"Secret message"
encryptor = key_pair.public_key.get_encryptor()
encrypted_message = encryptor.encrypt(message)

decrypted_message = key_pair.decrypt(encrypted_message)

Encrypting and Decrypting Streams

# Encrypting a stream
with open("path/to/input/file", "rb") as input_file:
    encryptor = key_pair.public_key.get_encryptor()
    for chunk in encryptor.encrypt_stream(input_file):
        output_file.write(chunk)

# Decrypting a stream
with open("path/to/encrypted/file", "rb") as encrypted_file:
    for chunk in key_pair.decrypt_stream(encrypted_file):
        decrypted_file.write(chunk)

Signing and Verifying Messages

signature = key_pair.sign(message)
is_valid = key_pair.public_key.verify(signature, message=message)

Encrypted data consists of:

Content Length
Key version 1 byte
Key id 8 bytes
Encrypted symmetric key Equal to key length (256-512 bytes)
Data encrypted via symmetric key Slightly larger than the length of original data and multiple of block length (<= len(original) + len(block))

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.

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

gnukek-2.0.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

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

gnukek-2.0.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file gnukek-2.0.0.tar.gz.

File metadata

  • Download URL: gnukek-2.0.0.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gnukek-2.0.0.tar.gz
Algorithm Hash digest
SHA256 ab2e9569a34a791aa8dc70f67687b624ce61729d4a2d6e1a06c93e5764b78b51
MD5 85a32156e8958e2f47e713b6013e6b73
BLAKE2b-256 9f4e317697ff49c938696a9a69108180903a432bd78d82178a34a1bdd6e032f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for gnukek-2.0.0.tar.gz:

Publisher: pypi.yml on SweetBubaleXXX/KEK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gnukek-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: gnukek-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gnukek-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5fa846e99a32c5c60a36941e1de15b5bdaedf758711f3fda9ddbb3356f8b963f
MD5 ae4390b5895b45eeaa1dd430e1d239b0
BLAKE2b-256 04df7042636bf9dd8e712ffc160052dc8f898bef987d2053546f62e2231d27e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for gnukek-2.0.0-py3-none-any.whl:

Publisher: pypi.yml on SweetBubaleXXX/KEK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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