Skip to main content

A Python library for encrypting and decrypting ASN.1 encrypted content.

Project description

asn1cipher

A Python library for encrypting and decrypting ASN.1 encrypted content. Uses asn1crypto library's EncryptionAlgorithm and EncryptedContentInfo.

Features

Algorithm Oid

  • PBES1 support (1.2.840.113549.1.5.X)
  • PKCS#12 encryption support (1.2.840.113549.1.12.1.X)
  • PBES2/PBKDF2 support (1.2.840.113549.1.5.13)

Cipher Algorithm

  • RC2 block cipher
  • Custom Block Cipher Support (BlockCipher abstraction)

Quick Start

Basic Usage

examples/basic_usage.py

from asn1cipher import Provider
from asn1crypto.algos import EncryptionAlgorithm, Pbes1Params
from asn1crypto.core import OctetString
import os

# Create Provider instance
provider = Provider()

# Data to encrypt and password
plaintext = b"Hello, World! This is a secret message."
password = b"my_secret_password"

# Configure PBES1 (SHA1 + DES) algorithm
encryption_algorithm = EncryptionAlgorithm({
    'algorithm': 'pbes1_sha1_des',
    'parameters': Pbes1Params({
        'salt': os.urandom(8),
        'iterations': 10000,
    })
})

# Encrypt
encrypted_content_info = provider.encrypt(
    plaintext=plaintext,
    password=password,
    encryption_algorithm=encryption_algorithm
)

# Decrypt
decrypted = provider.decrypt(
    encrypted_content_info=encrypted_content_info,
    password=password
)

assert decrypted == plaintext
print("✓ Encryption/decryption successful!")

License

Apache-2.0 License

Contributing

Contributions are welcome! Please submit a Pull Request.

Related Projects

Author

joseph@jc-lab.net

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

asn1cipher-0.0.2.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

asn1cipher-0.0.2-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file asn1cipher-0.0.2.tar.gz.

File metadata

  • Download URL: asn1cipher-0.0.2.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for asn1cipher-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ab94a872c5693ef73716e0217bc0bf6e3ad468c4452b4629c9194097ddaac03b
MD5 54640f41ea69f4057585728086e060c2
BLAKE2b-256 0cd66cf422b08e93f4ac8372364309923bc117f89d55582b24ec1acc4830b94d

See more details on using hashes here.

Provenance

The following attestation bundles were made for asn1cipher-0.0.2.tar.gz:

Publisher: pypi-publish.yml on jc-lab/asn1cipher

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

File details

Details for the file asn1cipher-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: asn1cipher-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for asn1cipher-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 060f416e0efb089d5b21db7c85359df7eedb01d16f90b9e08a75f52c01451bac
MD5 b41943ccb9bc36f9ffcad372893dcdbe
BLAKE2b-256 68ff90bf56d89c6e945ce14b208691e8056d22a8ee919b744fa2c4bcba483fc1

See more details on using hashes here.

Provenance

The following attestation bundles were made for asn1cipher-0.0.2-py3-none-any.whl:

Publisher: pypi-publish.yml on jc-lab/asn1cipher

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