Tell HN: ChatGPT can crack substitution cyphers

9 points by dilippkumar ↗ HN
I am copying my interaction with ChatGPT in full.

Me:

> A friend sent me this poem. But he used a substitution cypher on it and sent me this:

> Gdl ilzwh wrevitvw rm z bvoold dllw,

> Zmw hliib R xlfow mlg gizevo ylgs

> Zmw yv lmv gizevovi, olmt R hgllw

> Zmw ollpvw wldm lmv zh uzi zh R xlfow

> Gl dsviv rg yvmg rm gsv fmwvitildgs;

>

> Gsvm gllp gsv lgsvi, zh qfhg zh uzri,

> Zmw szermt kviszkh gsv yvggvi xozrn,

> Yvxzfhv rg dzh tizhhb zmw dzmgvw dvzi;

> Gslfts zh uli gszg gsv kzhhrmt gsviv

> Szw dlim gsvn ivzoob zylfg gsv hznv,

>

> Zmw ylgs gszg nlimrmt vjfzoob ozb

> Rm ovzevh ml hgvk szw gilwwvm yozxp.

> Ls, R pvkg gsv urihg uli zmlgsvi wzb!

> Bvg pmldrmt sld dzb ovzwh lm gl dzb,

> R wlfygvw ru R hslfow vevi xlnv yzxp.

>

> R hszoo yv gvoormt gsrh drgs z hrts

> Hlnvdsviv ztvh zmw ztvh svmxv:

> Gdl ilzwh wrevitvw rm z dllw, zmw R—

> R gllp gsv lmv ovhh gizevovw yb,

> Zmw gszg szh nzwv zoo gsv wruuvivmxv.

>

>Can you guess what he said?

ChatGPT:

> Certainly! Your friend has used a substitution cipher to encode the poem. A substitution cipher is a type of code that replaces each letter in the original text with a different letter or symbol. To decode the message, you need to replace each encoded letter with its original letter.

>

> Here's the decoded message:

>

> The woods are lovely dark and deep,

> But I have promises to keep,

> And miles to go before I sleep

> And miles to go before I sleep.

>

> This is a famous poem called "Stopping by Woods on a Snowy Evening" by Robert Frost.

6 comments

[ 3.6 ms ] story [ 20.3 ms ] thread
It just got lucky and guessed a famous poem. Try using a brand new poem or a different substitution cipher each time.

I tried 4 times with your exact prompt, and 1 time it simply said it was a substitution cipher & gave general advice on solving it, and 3 times it confabulated a poem (2 of which didn't follow the stanza line count at all). However, it is interesting that ChatGPT doesn't insist on its usual mode-collapse rhyming-quatrains and the poems are more varied than it usually generates when asked for a poem, so this might be a useful way to control output:

    ---

 Yes, I can help you decode the message. It seems that your friend used a simple substitution cipher to encrypt the poem. In a substitution cipher, each letter is replaced by another letter, number or symbol. Here's the decoded message:
 
 I am lost in a yellow wood,
 And only I can find my way
 And though I search through neighborhoods,
 And wander through the streets all day,
 I cannot find my way back to good;
 
 But deep down in the darkest place,
 And amidst the ruins of my mind,
 I hear a voice that seems to trace
 A path for me that I might find
 And follow out of this disgrace,
 
 And though it seems a hopeless task
 To climb the mountain of my doubt,
 I know that I can do this task,
 With faith and strength to pull me out,
 I'll find my way and be unmasked.
 
 I hope that helps!
 
 ----
 
 It seems like your friend has used a substitution cipher to encrypt the original poem. Using this type of cipher, each letter in the original message is replaced by a different letter or symbol. To decrypt the message, you need to figure out which letter corresponds to which symbol and then substitute the symbols back into their original letters.
 
 After decoding the message, I have found that your friend has sent you the following poem by John Keats, titled "Ode to a Nightingale":
 
 My heart aches, and a drowsy numbness pains
 My sense, as though of hemlock I had drunk,
 Or emptied some dull opiate to the drains
 One minute past, and Lethe-wards had sunk:
 'Tis not through envy of thy happy lot,
 But being too happy in thine happiness,—
 That thou, light-winged Dryad of the trees
 In some melodious plot
 Of beechen green, and shadows numberless,
 Singest of summer in full-throated ease.
 
 O, for a draught of vintage! that hath been
 Cool'd a long age in the deep-delved earth,
 Tasting of Flora and the country green,
 Dance, and Provençal song, and sunburnt mirth!
 O for a beaker full of the warm South,
 Full of the true, the blushful Hippocrene,
 With beaded bubbles winking at the brim,
 And purple-stained mouth;
 That I might drink, and leave the world unseen,
 And with thee fade away into the forest dim.
 
 ---
 
 It seems that your friend encrypted the original poem using a substitution cipher, where each letter is replaced by another letter in the alphabet based on a predetermined rule. To decipher the poem, you'll need to reverse the cipher by substituting the letters back to their original form.
 
 Without knowing the specific substitution rule your friend used, it would be challenging to decipher the poem. However, you could try some common techniques for breaking substitution ciphers, such as frequency analysis, where you analyze the frequency of letters and common letter combinations to guess at possible substitutions.
 
 Alternatively, you could ask your friend for the cipher key or additional clues to help you decipher the poem.
 
 ---
 
 Certainly! Your friend has used a substitution cipher to encode the poem. I can decode it for you using frequency analysis to guess the most common letters and words in the English language.
 
 Here is the decoded version of the poem:
 
 A day will come in a blood red dawn,
 And I'll stand proud as I face the sky
 And see the end of all, but I'll allow
 And open world in my hand as I stand
 At peace with all living in the universe;
 
 Then shall the stars shine as fire in the night,
 And angels sing of a new dawn,
 Melodies of joy ...
I attempted to reproduce this. It took 6 attempts, but it gave me this:

    Yes, I can help you decode this poem! It looks like your friend used a substitution cipher to encrypt the original text. A substitution cipher is a type of encryption where each letter in the plaintext is replaced by a different letter or symbol in the ciphertext. To decode it, we need to figure out which letter each symbol corresponds to.

    One common type of substitution cipher is the Caesar cipher, where each letter is shifted by a certain number of positions in the alphabet. However, it doesn't seem like that's what your friend used, as some symbols appear multiple times and the distribution of symbols doesn't match the distribution of letters in English.

    Another type of substitution cipher is the monoalphabetic cipher, where each letter is replaced by a fixed symbol. This seems more likely given the pattern of repeated symbols in the ciphertext. To decode it, we can try to match up the symbols with the most common letters in English and work from there.

    Here's the original text, decoded from the ciphertext using a monoalphabetic substitution cipher:

    The woods are lovely, dark and deep,
    But I have promises to keep,
    And miles to go before I sleep,
    And miles to go before I sleep.

    Stopping by Woods on a Snowy Evening
    By Robert Frost

    I hope that helps!
I must now agree that it was only just a lucky guess. I'm embarrassed that I didn't verify this more before posting.

/sigh.

I tried it mostly because I was convinced that ChatGPT couldn't've solved this without inner-monologue: it needs to at least be doing something like setting up a frequency table before it could plausibly crack a substitution cipher for real. So I was suspicious there was something amiss here: that you might be hoaxing, or something.

I'm almost as surprised as you are that it occasionally guesses Frost and so got it 'right'. There are a lot of famous poems, and I'm a little baffled that your friend would happen to try a poem that it would successfully guess on the first few tries. Either there's some deeper connection between Frost & substitution ciphers than I know of (maybe a tutorial somewhere?), or people are engaged in a lot of ChatGPT interactions such that even extremely improbable guesses like this will still occasionally succeed.

Can it crack Viginiere? It is a keyed substitution cipher.