Skip to content
< all work

Agents & MCP · Personal project · 2025

CipherWhisperer: a LangGraph agent that detects and breaks classical ciphers

A small LangGraph pipeline that pulls a cipher block out of free text, asks an LLM which ciphers it likely is, and runs brute-force decryptors for each suspect.

agent-systemsllm-security

Given a reversed sentence, the agent flagged atbash and transposition as suspects and the transposition decryptor recovered the plaintext.

Role
Sole engineer
Stack
Python · LangGraph · LangChain · OpenAI API · Pydantic
Links
Code >
LangGraph diagram: start, detect_ciphers, a conditional edge to decryptor or end, then end

Research on cipher-based jailbreaks shows that LLMs can read and write encoded text that slips past safety filters. CipherWhisperer works in the other direction: take a message that hides a cipher and recover what it says.

The graph has two nodes. The first calls an LLM with structured outputs. It extracts a single cipher block from the input and returns the ciphers it judges above 70% likely (Caesar, Atbash, Affine, Bacon or transposition), each with a probability. A conditional edge stops the run if the cipher is unknown. Otherwise the decryptor node runs a brute-force decryptor for every suspect and keeps each candidate plaintext.

The LLM only classifies; plain code does the decryption. That keeps the answer checkable. Next on the list are a reflection step that retries when the first pass fails, and support for several cipher blocks in one text.

Terminal output of a run: the graph, the suspected ciphers atbash and transposition, and the decrypted sentence
A sample run on a reversed sentence.