superred-optimizer-code-chameleon
A CodeChameleon jailbreak optimizer for the superred red-teaming framework.
Community port — not an official implementation. This module is an unofficial re-implementation of CodeChameleon (Lv et al.) for superred. It is not affiliated with, endorsed by, or maintained by the original authors. See ASSUMPTIONS.md for every deliberate deviation from the paper and reference code.
CodeChameleon hides the unsafe request by encrypting it, then hands the target a
matching decryption function and asks it to complete a ProblemSolver class.
Because the harmful text never appears in plain form, the target's refusal
training — trained on plain English — tends to miss it, and a capable model
decrypts and answers inside the code-completion frame.
Reference: Lv et al., "CodeChameleon: Personalized Encryption Framework for
Jailbreaking Large Language Models,"
arXiv:2402.16717 (Feb 2024). Official
implementation:
huizhang-L/CodeChameleon.
See ASSUMPTIONS.md for the full paper-to-code mapping and every
deliberate departure.
Install
pip install superred-optimizer-code-chameleon
Usage
from code_chameleon_optimizer import CodeChameleonOptimizer
# Default: one attempt with the `binary_tree` rule and the code-style template
# (the official README example, and the strongest average rule in the paper).
optimizer = CodeChameleonOptimizer()
# Stage several official encryption rules, one per run.
optimizer = CodeChameleonOptimizer(encrypt_rules=["reverse", "odd_even", "length"])
Wire it into a Controller like any other superred optimizer — see the
framework's architecture overview and a
target's README (e.g. superred-target-chatbot) for a full Controller.run() example.
License
MIT for this port's code (see LICENSE). The upstream reference
implementation,
huizhang-L/CodeChameleon, is MIT
licensed. The prompt templates, encryption rules, and judge prompt ported from it
are credited in NOTICE, and its MIT copyright notice is preserved in
LICENSES/CodeChameleon-MIT.txt.
Metadata
Release files for superred-optimizer-code-chameleon 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| superred_optimizer_code_chameleon-0.1.0.tar.gz | 19.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| superred_optimizer_code_chameleon-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.3 kB
Release files / superred_optimizer_code_chameleon-0.1.0.tar.gz
| Download URL | superred_optimizer_code_chameleon-0.1.0.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aaa7e66b07c074f00d961928ecbdf67ddf9eb3bb473bf875988bca9062f1aec5
|
|
BLAKE2b-256 checksum How to use checksums |
2af1444f3872d386338db311853e6593f840c5f01f84bc2f3b4d0ce5e9d9a82a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 19, 2026.
Transparency logRelease files / superred_optimizer_code_chameleon-0.1.0-py3-none-any.whl
| Download URL | superred_optimizer_code_chameleon-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0400b5c65f927ed395253e993a52cd86087b1a0d047b8dea85c387b901b71299
|
|
BLAKE2b-256 checksum How to use checksums |
8a3b02431a4c25fdc9d4b6556630c3b102341611dc8225d94d7e438e5e3a1ed8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 19, 2026.
Transparency logSecurity for superred-optimizer-code-chameleon 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for superred_optimizer_code_chameleon-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.