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.4.tar.gz (16.2 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.4-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asn1cipher-0.0.4.tar.gz
  • Upload date:
  • Size: 16.2 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.4.tar.gz
Algorithm Hash digest
SHA256 adb44447659c5aabc0f004efeeaed7a961f30a81f2ae996ae55afc877bcdb1f7
MD5 fe5340566d92e2fd19a70dcae09e247c
BLAKE2b-256 a456cccc42bac878245eb2459874a76acc0dcccfddf0f66dd94675bedbe37131

See more details on using hashes here.

Provenance

The following attestation bundles were made for asn1cipher-0.0.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: asn1cipher-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 17.6 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fcc948d54c97f22366cb16ff9888b53f933256292fe590e8c8e4527879a268d8
MD5 03249d7c93d91845430eae5220bbfa82
BLAKE2b-256 0375d4a0f0f320877ab9b4a93faebd1b567f3f36b1b092bd4712544103366379

See more details on using hashes here.

Provenance

The following attestation bundles were made for asn1cipher-0.0.4-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