This question already has an answer here:
- Decryption by pattern analysis 2 answers
Write a program or function that will break ciphers, using as few bytes as possible.
Given an encrypted message and a dictionary as input, output the decrypted message. The messages will be encrypted using a one-to-one character mapping, i.e. two characters can't both map to one, and vice versa. The message will only include words from the dictionary.
Take as input an encrypted message and a dictionary of words. The input can be taken in any form you like, however the preferred input is the message as a string and the dictionary as either a new-line deliminated string, an array or the file path of a file containing one word per line.
Output the decrypted message in any format you like (although human-readable is preferred). The output must only contain words from the message.
These examples assume that the dictionary given is an English dictionary, such as the one included in Linux:
TLW EYQMA HJUIP BUN VYKZWR UDWJ TLW FCXS RUG FCOT IWWAWPR HYT TLWP PUTQMWR TLCT TLQO OWPTWPMW PWWRWR CRRQTQUPCF IUJRO TU HW WCOQFS BQNWR OU TLW BUN COAWR TLW RUG TU GWT CPUTLWJ OWPTWPMW, CPR ILWP TLW RUG JWBYOWR TLW BUN MJWCTWR UPW QPOTWCR the quick brown fox jumped over the lazy dog last weekend but then noticed that this sentence needed additional words to be easily fixed so the fox asked the dog to get another sentence and when the dog refused the fox created one instead VMXIBKGVW GVCG RH HLNVGRNVH XIVZGVW YB IVKOZXRMT LMV OVGGVI YB ZMLGSVI GSRH GVCG GVHGH BLF GL VMHFIV BLF XZM IVKOZXV HLNV LI ZOO LU GSV OVGGVIH RM GSV GVCG DRGS IVKOZXVNVMG OVGGVIH encrypted text is sometimes created by replacing one letter by another this text tests you to ensure you can replace some or all of the letters in the text with replacement letters