SQUANDER CRPTOGRAPHY

Ads

 
 

Share on Google+Share on Google+

Laian Joy Chavez
SQUANDER CRPTOGRAPHY
0 Answer(s)      6 years and 2 months ago
Posted in : Java Beginners

In Dorothy Sayers' novel "Have His Carcass", Lord Peter Wimsey describes a cryptography technique that is simple for encoding and decoding, yet relatively hard to crack. Your job is to implement this technique. Here's how it works, in Sayers' (edited) words: You choose a key-word of six letters or more, none of which recurs. Such as, for example, SQUANDER. Then you make a diagram of five squares each way and write the key-word in the squares like this: Then you fill up the remaining spaces with the rest of the alphabet in order, leaving out the ones you've already got. You can't put twenty-six letters in twenty-five spaces, so you pretend you're an ancient Roman or a medieval monk and treat I and J as one letter. So you get this: Now let's take a message -- What shall we say? 'All is known, fly at once' -- that classic hardy perennial. We write it down all of a piece and break it into groups of two letters, reading from left to right. It won't do to have two of the same letters coming together in a pair, so where that happens, we shove in a Q, which won't confuse the reader. Now our message runs: AL QL IS KN OW NF LY AT ON CE If there is an odd letter at the end, we'd add on another Q to square it up. Now we take our first group, AL. We see that they come at the corners of a rectangle in which the other corners are SP. So we put down SP for the first two letters of the coded message. In the same way, QL becomes SM and IS becomes FA. Ah, but here's KN. They both come on the same vertical line. In this case you take the letter next below each -- TC. Next comes OW, which translates to MX. Going on, SK, PV, NP, TU... If your first diagonal went from bottom to top, you must take it the same way again. ON = TU, NO would be UT. CE comes on the same horizontal line. In that case, you take the letter to the right of each. Since there isn't a letter to the right of C, you start again at the beginning of the line, producing DR. Your coded message stands now: SP SM FA TC MX SK PV NP TU DR The input for your program will be a series of keywords and messages to encode, alternating line-by-line, until the end-of-file flag of 999. Using the above technique, you are to encode the message, using the word.

Example

Input SQUANDER ALL IS KNOWN FLY AT ONCE JUXTAPOSITION THE ROOSTER CROWED AT MIDNIGHT 999 Input will be in upper case and will contain no punctuation. Letters may occur more than once in the keywords, in which case you must ignore all but the first occurrence of the letter.

Output Print each message, encrypted, using two letter groups and no punctuation, separated by a single white space. SP SM FA TC MX SK PV NP TU DR Print an I for IJ.

Notes: If the last letter is both odd and repeated, treat it as repeated and put the 'Q' before it, not afterward. That is, ALL becomes ALQL for encoding purposes. In the unlikely case of two Qs in a row, insert a Z between them. Also, augment oddlength messages ending with a Q by using a Z. Thus, FAQQAD becomes FAQZQADQ and HUQ becomes HUQZ for encoding.

Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
SQUANDER CRPTOGRAPHY
SQUANDER CRPTOGRAPHY  In Dorothy Sayers' novel "Have His Carcass... letters or more, none of which recurs. Such as, for example, SQUANDER. Then you... together in a pair, so where that happens, we shove in a Q, which won't confuse
SQUANDER CRPTOGRAPHY
SQUANDER CRPTOGRAPHY  In Dorothy Sayers' novel "Have His Carcass... letters or more, none of which recurs. Such as, for example, SQUANDER. Then you... together in a pair, so where that happens, we shove in a Q, which won't confuse
Advertisements
Tutorials   
Java Spring Hibernate Struts Training How do beginners learn about Java? ClassNotFoundException HttpRequestInterceptor java.lang.noclassdeffounderror: org/apache/http/httprequest noclassdeffounderror: org/apache/http/client/methods/httpurirequest java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history

Ads

 
Advertisement null

Ads