michaeld.network

Computer Networking | Software Engineering


interests blog

Encoding ciphertext with ChatGPT into a linkedin post

November 24, 2024

The goal of this project is to encode the answers to a few trivia questions as ciphertext into the normal text of a post I have made on linkedin.

The ciphertext encoding should be simple enough that a few of the questions can be answered by people who like puzzles, but complex enough that all of the answers cannot be derived from a trivial analysis. I also do not want to spend a large amount of time researching ciphertext algorithms. They are of passing interest to me, enough that I’d like to include them in a personal post, but I am not an expert in that area nor do I derive enough pleasure from it to make it a hobby topic. I’ve always found the Caesar Cipher to be a useful example as an introduction to security concepts, given it is over 2000 years old, and I do not want the ciphertext encoding in the article to be much more complicated than that substitution cipher.

I also have a self-imposed deadline of the end of the month to achieve this encoding and there is only a few weeks until this month ends.

This seemed like a perfect opportunity to explore ChatGPT more and see how useful a LLM could be for this type of task.

I thought that ChatGPT would be interesting for this task for the following reasons:

Cipher Text Research Phase

Below is the set of questions I asked to begin to investigate potential ciphers.

Question:

Please provide a brief summary of encoding ciphers for plaintext. (Encoding Ciphers Overview)

Answer: … several paragraphs which I do not want to reproduce here.

Question:

Please condense the response further.

Answer:

Encoding ciphers transform plaintext to obscure or protect its meaning:

 1. Substitution Ciphers: Replace characters (e.g., Caesar, Vigenère).
 2. Transposition Ciphers: Rearrange character positions (e.g., Rail Fence, Columnar).
 3. Modern Encodings: Encode data for readability/safety (e.g., Base64, Hex).
 4. Hashing: Irreversible conversion for verification (e.g., MD5, SHA-256).
 5. Encryption Ciphers: Secure data (e.g., AES for symmetric, RSA for asymmetric).

Simple ciphers are educational, while encryption is essential for security.

Question:

Please briefly give more examples of Substitution and Transposition Ciphers.

Answer:

Substitution Ciphers

 1. Atbash Cipher: Reverses the alphabet (e.g., A ↔ Z, B ↔ Y).
 2. Playfair Cipher: Substitutes digraphs (pairs of letters) using a key matrix.
 3. Homophonic Cipher: Maps each letter to multiple substitutes to reduce frequency patterns.

Transposition Ciphers

 1. Scytale Cipher: Wraps text around a rod to reveal the message.
 2. Double Columnar Transposition: Applies columnar rearrangement twice with different keys.
 3. Route Cipher: Arranges text in a grid, then reads it in a specific order (e.g., spiral).

Question:

Please give a one line description of each of: Caesar Cipher, Monoalphabetic Cipher, Polyalphabetic Cipher, Rail Fence Cipher, Columnar Transposition

Answer:

 1. Caesar Cipher: Shifts each letter by a fixed number of positions in the alphabet.
 2. Monoalphabetic Cipher: Replaces each character with a fixed substitute from a single alphabet.
 3. Polyalphabetic Cipher: Uses multiple substitution alphabets based on a repeating key.
 4. Rail Fence Cipher: Writes text in a zigzag pattern and reads it row by row.
 5. Columnar Transposition: Writes text in rows of a grid and rearranges the columns using a key.

This above seemed to provide a good overview of possible ciphers I could use to encode my text in and the overview was constructed and provided very quickly. Overall this was no more than 3 minutes of interaction with the LLM.

Application of specific ciphers to text

I had 5 questions that I wanted to encode into the text and I wanted to use a variety of ciphers with increasing difficulty.

Using Caesar Cipher (ROT-3)

Question:

Using a ROT-3 cipher encrypt the plaintext "ANSWERTWO"

Answer:

Final Ciphertext:

"DQVZHUWWZR"

Question:

Using a ROT-2 cipher decrypt the ciphertext "DQVZHUWWZR"

Answer:

Final Decrypted Message:

"ANSWERTWO"

Attempting to generate a monoalphabetic cipher

Question:

Generate the full alphabet

Answer:

Here’s the full English alphabet:

ABCDEFGHIJKLMNOPQRSTUVWXYZ

Question:

Generate the full alphabet but start the alphabet with oxfrd and print only the remaining letters in the alphabet in order.

Answer:

Starting with "OXFRD" and printing the remaining letters in order:

ABCDEFGHIKLMNPQSTUVWYZ

(Excluding "O", "X", "F", "R", "D".)

Question:

Generate the alphabet but exclude oxfrd

Answer:

The alphabet excluding "OXFRD" is:

ABCDEFGHIKLMNPQSTUVWYZ

Question:

Generate the alphabet but exclude the letters o,x,f,r,d

Answer:

The alphabet excluding the letters "O", "X", "F", "R", and "D" is:

ABCEGHIJKLMNPQSTUVWYZ

Question:

Combine the alphabet excluding the letters o,x,f,r,d with the prefix "oxfrd"

Answer:

Combining the prefix "OXFRD" with the alphabet excluding "O", "X", "F", "R", and "D" results in:

OXFRDABCEGHIJKLMNPQSTUVWYZ

After this question I received “You’ve hit the Free plan limit for GPT-4o. Responses will use another model until your limit resets after 5:37 PM.”

Question:

Using the cipher alphabet "OXFRDABCEGHIJKLMNPQSTUVWYZ" encrypt the plaintext "ANSWERTHREE"

Answer:

"OPQTDATBADD"

This is the ciphertext for the plaintext "ANSWERTHREE" using the given cipher alphabet "OXFRDABCEGHIJKLMNPQSTUVWYZ".

Question:

Using the ciphertext "OPQTDATBADD" and the cipher alphabet ""OXFRDABCEGHIJKLMNPQSTUVWYZ" decrypt the ciphertext.

Answer:

Final Decrypted Message:

"ANSWERTHREE"

This is the original plaintext corresponding to the ciphertext "OPQTDATBADD" using the given cipher alphabet "OXFRDABCEGHIJKLMNPQSTUVWYZ".

However the actual answer was a bit more obvious to see with this cipher alphabet so I decided to reverse it.

Question:

Combine the alphabet in reverse, excluding the letters o,x,f,r,d, with the prefix "oxfrd"

Answer:

OXFRDZYWVUTSQPNMLKJIHGECBA

Question:

Using the cipher alphabet "OXFRDZYWVUTSQPNMLKJIHGECBA" encrypt the plaintext "ANSWERTHREE"

Answer:

Final Ciphertext:

"OPQTDZYWZDD"

Question:

Using the ciphertext "OPQTDZYWZDD" and the cipher alphabet "OXFRDZYWVUTSQPNMLKJIHGECBA" decrypt the ciphertext

Answer:

Final Decrypted Message:

"ANSWERTHREE"

Attempting to encrypt and decrypt using the playfair cipher

Question:

Encrypt the plaintext "ANSWERFOUR" using the playfair cipher and the keyword "OXFRD" and describe the process.

Answer:

...
Final Ciphertext:

The ciphertext for "ANSWERFOUR" using the Playfair cipher with the keyword "OXFRD" is "HUTYLERXZD".

Question:

Decrypt the ciphertext "HUTYLERXZD" using the Playfair cipher and the keyword "OXFRD".

Answer:

...
The plaintext for "HUTYLERXZD" using the Playfair cipher with the keyword "OXFRD" is "ANSWERFOUR".

This did not result in a successful conversion so I used a website.

Attempting to encrypt and decrypt using the vigenere cipher

Question:

Encrypt the plaintext "ANSWERFIVE" using the vigenere square and the keyword "OXFRD"

Answer:

...
The encrypted ciphertext is: "OKXJHKADOH"

Question:

Decrypt the ciphertext "OKXJHKADOH" using the vigenere square and the keyword "OXFRD"

Answer:

...
The plaintext for "OKXJHKADOH" using the Vigenère cipher with the keyword "OXFRD" is "ANSWERFITE".

Where it seems to have gone wrong:

Step 2: Repeat the Keyword to Match the Length of the Plaintext

The plaintext "ANSWERFIVE" has 11 letters, so we need to repeat the keyword "OXFRD" to match the length of the plaintext:

    Plaintext: A N S W E R F I V E
    Keyword:   O X F R D O X F R D O

What is interesting is given the correct letter ‘M’ for the vigenere square it still produced the wrong answer for the 9th letter.

Question:

Decrypt the ciphertext "OKXJHKADMH" using the vigenere square and the keyword "OXFRD"

Answer:

...
Final Plaintext:

The decrypted message for "OKXJHKADMH" using the Vigenère cipher with the keyword "OXFRD" is "ANSWERFITE".

Compared to a website for this cipher.

Encoding the ciphertext into the article

With my ciphertext compiled I now need to come up with a scheme to encode the ciphertext into the article. The ciphertext below was interim text, not what I finally encoded.

ESSMARKHAM|SDYHUGQHV|SFQDOMRXSFTM # All answers in series
ESSMARKHAMSDYHUGQHVSFQDOMRXSFTM # All answers with demarcation removed
E,S,S,M,A,R,K,H,A,M,S,D,Y,H,U,G,Q,H,V,S,F,Q,D,O,M,R,X,S,F,T,M # # vim substitution to insert commas '<,'>s/\([A-Z]\)/\1,/g

I used vim macros to transform my text into only the first sentences of each paragraph. )v$xjj for those who are vimthusiasts

From there I tried the following prompt: Using the text below as a starting point, change each sentence so that they start with with the letters E,S,S,M,A,R,K,H,A,M,S,D,Y,H,U,G,Q,H,V,S,F,Q,D,O,M,R,X,S,F,T,M

It produced the following text which is 33 sentences.

Eagerly, I pursued the dream of Graduating with Distinction in a Masters programme from Oxford, something that seemed unimaginable until recently.
Sitting in the Sheldonian Theatre for the first time in March of 2019, I reflected on having completed an Advanced Diploma in IT Systems Analysis and Design through Oxford's Continuing Education department.
Starting to entertain the idea more seriously over the remainder of the year, a plan began to take shape as I delved into the details of the programme.
Motivated by my recent success in passing a Redhat Certified Engineer exam, my appreciation for Linux and open-source software had grown exponentially in recent years.
Afterward, I recalled how, early in my career, I had tackled a similar challenge, earning 23 vendor certifications to become the fourteenth Brocade Distinguished Architect in the world.
Researching the programme thoroughly, I decided to apply based on its feasibility, alignment with my career aspirations, and encouragement from my wife and father, who assured me that I could succeed if accepted.
Knowing the importance of being well-prepared, I studied the software engineering website for guidance and inspiration.
Happily, I submitted my application in December 2019 and was soon invited to an interview scheduled for February 2020.
Awaiting my term to begin, I watched as the world became increasingly uncertain and tumultuous.
Making plans for my first course, my partner and I traveled to Oxford to pick up my student ID, which I had read was required to access the building.
Speculating about a second spike in COVID-19 cases, concerns grew that the National Health Service (NHS) might become overwhelmed, and by October 19th, a second lockdown was announced.
Dealing with these disruptions, the university had adapted to virtual learning for most of 2020 and laid out plans to continue educating students despite the lockdown.
Yielding to this format, the programme’s structure featured week-long intensive courses culminating in exams released at the end of each session.
Hoping to excel, my initial goal was simply to pass and earn my degree, but my first result motivated me to aim for Distinction and explore the effort required for top marks.
Understanding that circumstances might improve, I optimistically scheduled my 2nd, 3rd, 4th, and 5th courses, believing I could attend in person by year’s end.
Gathering momentum in winter 2020, I faced the reality of juggling studies with parenthood in spring 2021 as we welcomed our first child without family support nearby.
Quietly, I began tackling the security curriculum in winter 2021, determined to maintain pace for completing the programme within the defined 3-4 year limit.
Hearing discussions about in-person learning returning in 2022, I remained focused, having completed four virtual courses.
Visiting potential neighborhoods, I shared my story with the letting agents at Penny & Sinclair, who kindly arranged a visit to a family-friendly area in Jericho.
Savoring the moment, my first in-person course, Network Security, felt worth the wait.
Focusing on dissertation preparation, the University recommended a nine- to twelve-month gap between coursework completion and dissertation submission for thorough research and writing.
Quickly, I adapted to the pace, completing five in-person courses and an intensive project week between our September 2022 arrival in Oxford and July 2023.
Determined, I pushed through a hectic summer, completing my 9th course on my birthday, submitting its assignment two weeks later, and beginning my projects week in the same period.
Overwhelmed, I received news of my sister’s hospitalization on the Wednesday before my final course.
Mourning, I flew to her funeral the following week while continuing work on my 9th exam and drafting my dissertation proposal during the trip.
Resolutely, by August 2023, I had finished 10 courses and achieved high enough marks to average a Distinction across the programme’s coursework.
Xenial times stretched into winter as my dissertation development continued through Christmas and into the new year.
Stressed, I faced incredible pressure leading up to my May submission deadline.
Fulfilling my aspirations, I learned by mid-summer 2024 that I had earned a Distinction on my dissertation.
Triumphant, I can confidently say there is no course in the programme I regret experiencing.
Mastering core areas, courses such as NES solidified my expertise in their respective fields.
Thankful, I owe much to the support of my colleagues and workplaces throughout this journey.
Magnanimously, I would like to thank my family, who stood by me through every challenge and triumph.

The ciphertext is 31 characters and the number of sentences are 33. It still produced and transformed the final 2 sentences.

ESSMARKHAMSDYHUGQHVSFQDOMRXSFTM    # Ciphertext
ESSMARKHAMSDYHUGQHVSFQDOMRXSFTMTM  # First letters of transformed text

The sentence construction sounds forced, and I had to look up the word Xenial, but it seems to have produced what I asked for.

The ciphertext for the remaining two answers appears to be more challenging to encode, with letters like Q,X,Z used more than once. So I decided not to use those encoding methods.

EOOTGXKCXKBIO|QXSKICOLVWZBR
EOOTGXKCXKBIOQXSKICOLVWZBR
E,O,O,T,G,X,K,C,X,K,B,I,O,Q,X,S,K,I,C,O,L,V,W,Z,B,R  # vim substituion to insert commas '<,'>s/\([A-Z]\)/\1,/g

Deciding to switch it up

At this point I switched the order of the questions as the combination of 3 answers was close to the original 33 paragraphs. I also decided to reduce from 5 questions to 4.

ESSMARKHAM    = 10 = 1
SDYHUGQHV     = 9  = 2
FOQLDPNZRLKRS = 13 = 3
SFQDOMRXSFTM  = 12 = 4

10 + 9 + 13 = 32

Question:

Using the text below as a starting point, change each sentence so that they start with with the letters E,S,S,M,A,R,K,H,A,M,S,D,Y,H,U,G,Q,H,V,F,O,Q,L,D,P,N,Z,R,L,K,R,S: <sentences inserted here>

This resulted in a set of sentences with the following letters:

ESSMARKHAMSDYHUGQHVFOQLDPNZRLKRS
ESSMARKHAMSDYHUGQHVFOQLDPNZRLKRST

I ended up using these sentences as references, but nearly all of them I restructured differently. It was somewhat helpful for finding synonyms that began with the letter I was considering, but google search results for synonyms were of equal use.

To avoid the extra ‘T’, and not confuse investigators, I merged the final two paragraphs of ‘thanks’.

I re-arranged the answers so that encodings with simpler letters (i.e. not Z,X,Q,Y) were not as frequent.

I also decided to leave the 4th answer un-encoded but use a different arrangement in the text. This fourth answer is the first letter of the last sentence in each paragraph, for paragraphs that contain more than one sentence.

If you’ve made it this far you must have read the linkedin post and at least skimmed this blog post, so I will reward you with these clues:

I used a monoalphabetic cipher with the cipher alphabet below for the answer to the 3rd question. Attempting this encoding with ChatGPT yielded the following ciphertext response, which I’ve intentionally encoded into the post.

Question:

Using the cipher alphabet "OXFRDZYWVUTSQPNMLKJIHGECBA" encrypt the plaintext "CANTFORGETLEM"

Answer:

To encrypt the plaintext "CANTFORGETLEM" using the cipher alphabet "OXFRDZYWVUTSQPNMLKJIHGECBA," follow these steps:

    Write the standard alphabet and the cipher alphabet side by side:

    Plain:  ABCDEFGHIJKLMNOPQRSTUVWXYZ
    Cipher: OXFRDZYWVUTSQPNMLKJIHGECBA

    For each letter in the plaintext, find its position in the standard alphabet and replace it with the corresponding letter from the cipher alphabet.

Encryption Process

    C → 3rd letter in plain alphabet → F (3rd letter in cipher alphabet)
    A → 1st letter in plain alphabet → O (1st letter in cipher alphabet)
    N → 14th letter in plain alphabet → Q (14th letter in cipher alphabet)
    T → 20th letter in plain alphabet → L (20th letter in cipher alphabet)
    F → 6th letter in plain alphabet → D (6th letter in cipher alphabet)
    O → 15th letter in plain alphabet → P (15th letter in cipher alphabet)
    R → 18th letter in plain alphabet → N (18th letter in cipher alphabet)
    G → 7th letter in plain alphabet → Z (7th letter in cipher alphabet)
    E → 5th letter in plain alphabet → R (5th letter in cipher alphabet)
    T → 20th letter in plain alphabet → L (20th letter in cipher alphabet)
    L → 12th letter in plain alphabet → K (12th letter in cipher alphabet)
    E → 5th letter in plain alphabet → R (5th letter in cipher alphabet)
    M → 13th letter in plain alphabet → S (13th letter in cipher alphabet)

Encrypted Text

The ciphertext is: FOQLDPNZRLKRS

But this is just a hallucination. The actual encoding would be:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
OXFRDZYWVUTSQPNMLKJIHGECBA

FOPIZNKYDISDQ
CANTFORGETLEM

Let the false encoding be a reminder of the perils of hallucination.