Crack the Cipher

2

Write a program or function that will break ciphers, using as few bytes as possible.

Task

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.

Input

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

Output the decrypted message in any format you like (although human-readable is preferred). The output must only contain words from the message.

Examples

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

wizzwizz4

Posted 2016-03-17T20:21:29.657

Reputation: 1 895

Question was closed 2016-03-18T14:53:29.993

5Related – AdmBorkBork – 2016-03-17T20:26:50.343

Related. – Martin Ender – 2016-03-17T20:57:27.963

This is not a duplicate; that one has a hard-coded dictionary, this one uses an external dictionary. – wizzwizz4 – 2016-03-24T17:38:43.283

No answers