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
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
- asn1crypto - ASN.1 parsing and serialization
- cryptography - Python cryptography library
Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adb44447659c5aabc0f004efeeaed7a961f30a81f2ae996ae55afc877bcdb1f7
|
|
| MD5 |
fe5340566d92e2fd19a70dcae09e247c
|
|
| BLAKE2b-256 |
a456cccc42bac878245eb2459874a76acc0dcccfddf0f66dd94675bedbe37131
|
Provenance
The following attestation bundles were made for asn1cipher-0.0.4.tar.gz:
Publisher:
pypi-publish.yml on jc-lab/asn1cipher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asn1cipher-0.0.4.tar.gz -
Subject digest:
adb44447659c5aabc0f004efeeaed7a961f30a81f2ae996ae55afc877bcdb1f7 - Sigstore transparency entry: 661420835
- Sigstore integration time:
-
Permalink:
jc-lab/asn1cipher@b8d9cf98dd47eb9ecf0a590c4a738a21a0be8a43 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/jc-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@b8d9cf98dd47eb9ecf0a590c4a738a21a0be8a43 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcc948d54c97f22366cb16ff9888b53f933256292fe590e8c8e4527879a268d8
|
|
| MD5 |
03249d7c93d91845430eae5220bbfa82
|
|
| BLAKE2b-256 |
0375d4a0f0f320877ab9b4a93faebd1b567f3f36b1b092bd4712544103366379
|
Provenance
The following attestation bundles were made for asn1cipher-0.0.4-py3-none-any.whl:
Publisher:
pypi-publish.yml on jc-lab/asn1cipher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asn1cipher-0.0.4-py3-none-any.whl -
Subject digest:
fcc948d54c97f22366cb16ff9888b53f933256292fe590e8c8e4527879a268d8 - Sigstore transparency entry: 661420847
- Sigstore integration time:
-
Permalink:
jc-lab/asn1cipher@b8d9cf98dd47eb9ecf0a590c4a738a21a0be8a43 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/jc-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@b8d9cf98dd47eb9ecf0a590c4a738a21a0be8a43 -
Trigger Event:
push
-
Statement type: