<img height="1" width="1" style="display:none" src="https://q.quora.com/_/ad/aa0df465f5e145b99c2e3c66e3450b19/pixel?tag=ViewContent&amp;noscript=1">

I am always looking for applications for the wide variety of Altair tools in my everyday life. One such application I found recently was to use Altair Compose as a simple cipher breaker. Now, before you start wondering what is so interesting about basic cryptography or why I was writing decryption scripts in my free time, a little bit of backstory is necessary here. 

Earlier this past summer, the popular fast food restaurant Chipotle released a string of puzzles over the course of a few weeks, where each one was a different type of puzzle and had a unique reward. For example, one puzzle was simply the phrase “stop only for rain if there’s a storm tracking above certain objects” repeated three times in a row. Figure 1, below, shows the mystery on Chipotle’s mobile app, with basically no other information provided.

ezgif.com-gif-maker - 2022-12-29T093839.017Fig 1: Puzzle Example

The solution to this one was to take the first letter of each word, which comes out to SOFRITASTACO three times in a row, and upon providing the solution, patrons were offered three free Sofritas Tacos, fittingly so. There were a few more of these puzzles, but my favorite was an apparent random collection of letters seen in Figure 2.

ezgif.com-gif-maker - 2022-12-29T093855.887Fig 2: Cipher Puzzle

If the “jumbled-up-ness” of the puzzle wasn’t enough of a clue, the description right above it almost outright tells customers that it is a cipher of some sort. When I saw it, I made the assumption that it was a simple Caesar Shift Cipher (I thought anything else would have been a little too complex for a fast-food rewards program), which eventually turned out to be a safe assumption. 

Just for clarification, this simple cipher is probably the one you used as a kid, where a shift of 2 turns A to C, B to D, C to E, etc. So naturally I went to my computer, opened Altair Compose, and got to work. Would it have been faster to search for an automatic cipher or decryption tool online? Yes, but I’m an engineer and I knew I would have more fun creating my own solution to this creative problem.

Solving the Cipher

My first approach was honestly a bit crude, but I was able to extract an answer: 
I took the input text “Gljlwdo phqx hafoxvlyh wdvwhv ehvw zkhq mxqlshu ehuulhv eulqj iodyru,” converted to upper-case (which isn’t totally necessary, but it made my life a little easier), and translated all characters, excluding spaces, to their respective ASCII values. 

For example, ‘G’ became 71, ‘l’ was changed to ‘L’ and became 76, ‘j’ to ‘J’ to 74, and so on throughout the entire puzzle, which was just a few lines of code in the Altair Compose Open Matrix Language (OML). 

From there, I just looped through the ASCII values 26 times, adding one each time. I had to be mindful to loop back to 65 or ‘A’ if the value reached 90 or ‘Z,’ which was accomplished with a basic built-in mod function. 
Lastly, I converted the array of ASCII values back to characters, and printed all the results, seen in Figure 3 below. From the console, I can manually inspect and find the original phrase based on which one looks the most like a real sentence. 

ezgif.com-gif-maker - 2022-12-29T093908.574Fig 3: Conversion to ASCII values

I found it a quite tedious to have to search through all possible cipher shifts, though, so I decided to make an upgrade. I used the built-in function in Altair Compose to request user input in the console to let a user decide if the answer was correct after each attempted decryption. 

I can look at the output, decide if it is made of real words, and type “No” or “n” to tell the program to keep trying, or type “Yes” or “y” to tell it to stop since it has found the correct answer. From Figure 4, below, you can probably already tell that this really didn’t make the program any better, since it requires a user to interact up to 26 times for one decryption. I also noticed that I should most likely attempt to decrypt the message by going backwards in the alphabet, since most simple ciphers shift forwards by only a few letters.

ezgif.com-gif-maker - 2022-12-29T093919.794Fig 4: User Input

After reversing the decryption and only needing to type “n” three times instead of twenty-three, I still wanted more automation in the process. Compose is designed to automate tedious tasks, after all. My dream was to have the script decide once the final answer was reached, instead of relying on user input. 
I considered translating the program to Python, which I could have done within the built-in Python IDE (integrated development environment) within Compose, and then importing a spellchecker in Python to determine if the output consisted of real words or not. I didn’t want to do that, though, since I had already organized the OML just how I wanted it. I found an even more direct solution: I downloaded a CSV (comma separate value) file that contains most English words you would find in a dictionary, courtesy of the Gutenberg Project. The final step was to add a condition that checks each word against the contents of the “Dictionary” to make sure they are present. 

I assumed in this project that the solution would be made of real words, not shorthand or slang, so I could ignore any results that had ‘words’ that were not in the list of acceptable words. One might expect this to seriously slow the program down, but the built-in file reader and data structures of Compose allowed me to quickly import the list and check each solution. 

You can see the final results in Figure 5, below, where the cipher shift value is shown (both for shifting forwards the long way and shifting back the short way it would have actually been encrypted), the translated output, and the surprisingly quick decryption time. With the powerful tools of Compose and just a little bit of “know-how”, I was able to solve the new Chipotle riddle in a fun and unique way, while also showing off the unending array of applications within the Altair suite of tools.  

ezgif.com-gif-maker - 2022-12-29T093933.520Fig 5: Final Results

And now it’s time to address the question you are all probably asking: What exactly does “Digital menu exclusive tastes best when juniper berries bring flavor” even mean? Well, I had to ask my girlfriend this (as she loves Chipotle even more than I do), and she let me know that they season their carnitas quesadillas with juniper berries. We eventually figured out the “Digital Menu Exclusive” part referred to ordering on the app (of course), so we went to place a mobile order, where we received a free carnitas quesadilla and some rewards points.

This was a fun example of Altair Compose that shows that our tools aren’t always completely restricted to one application, and it’s possible to be creative and make something very different that what you normally see in engineering software. If you have any questions about this program, this tool, or any of Altair’s products, don’t hesitate to contact us! 

Submit a comment

You may also like

Solving and Visualizing Differential Equations in Altair Compose
Solving and Visualizing Differential Equations in Altair Compose
1 March, 2023

Although many software suites and engineering tools are capable of automatically applying numerical solutions to differe...

Creating Lattice Structures with Altair Sulis
Creating Lattice Structures with Altair Sulis
10 January, 2023

Altair Sulis, formerly Gen3D, was acquired by Altair last year to bolster the Design for Additive Manufacturing (DFAM) p...