I am working on a way to decipher some text generated by a small piece of code (see below).
This piece of code swaps letters in the sentence at random and was wondering if there where any techniques to solve this? I have tried frequency analysis, however because it is not a simple substitution cipher this does not work.
Here is the text:
NBWHJO MIIOI CAMC JSERIXSMBO FMQ QOOWHT M QWKMZSO WHJBOMQO WH OBBEBQ WH CBMXXWJ XEB WCQ JRQCEPOBQ ZOJMRQO CAO MCCMJV FMQ MXXOJCWHT WHXBMQCBRJCRBO NBEGWIOBQ SWVO TWCARZ. "WX M JRQCEPOB'Q QWCO WQ NEWHCWHT CE M TWC CAOBO, HEF FO JMH'C BOMJA TWCARZ," AO QMWI. "CAOBO MBO IOXWHWCOSY WHXBMQCBRJCRBO NBEGWIOBQ CAMC FO JMH'C BOMJA.
Here is the code (Python)
import random def shuffle(string): string = list(string) for i in range(0, len(string)): # Choose two random letters in the string index_one = random.randint(0, len(string)-1) index_two = random.randint(0, len(string)-1) # Swap letters buffer = string[index_one] string[index_one] = string[index_two] string[index_two] = buffer return ''.join(string)