Solved

monoalphabetic cypher

Posted on 2006-11-17
4
384 Views
Last Modified: 2008-01-09
im fairly new to cryptography, my aim is to write a program which can perform ceaser cypher on a input string and output the result in groups of 5 i.e. : kkkkk-jjjjj-lllll-mmmmm

as far as i understand i have to take letters from the input string and shift a certain amount of characters down the alphabet, which i can do.  however im having difficulties understanding how i will output the results in groups of 5 if the string is less than 5 characters long.

im implementing it in java so i will be greatful for any examples

cheers
0
Comment
Question by:isarasoo
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 125 total points
ID: 17970354
You can pad it with extra characters to make a multiple of 5
0
 
LVL 10

Expert Comment

by:fostejo
ID: 17971220
isarasoo,

The problem you have here is that the Caesar Cipher is fundementally designed to replace each character in the string to be "encrypted" with another known character somewhere else in the alphabet.

Therefore, an input string of 'n' characters long must also have "encrypted" version of 'n' characters long.

Padding any string that's not a multiple of 5 characters with anything will compromise the end result (which isn't in any way secure anyway, BTW!) - probably the 'best' you could do was to indicate padded characters with a non-alphabetic character... but that isn't really a classic Caesar Cipher and immediately tells any potential 'decryptor' that those characters can be ignored anyway.

I think the solution here would be to remove the imposed limitation.. ie. Is it really critical that you must output in groups of 5?

I'm no Java expert so can't help with the code on that front I'm afraid, but the following page gives more info about the Caesar Cipher and includes links at the bottom to some other resources including sample code.

Hope that helps..
0
 
LVL 10

Expert Comment

by:fostejo
ID: 17971879
Oops, sorry isarasoo,

Just noticed I didn't give you the link!   ;)

http://en.wikipedia.org/wiki/Caesar_cipher

0
 
LVL 16

Expert Comment

by:AlexNek
ID: 17972938
> im having difficulties understanding how i will output the results in groups of 5 if the string is less than 5 characters long.

first, to check how many symbols in the input line. If less than 5 that write less than 5 symbols in output string too. Or you can first count the group numbers by dividing symbols numbers by 5.
Here is my pseudo code for output.

    for (int i = 0; i < outString.Length; i++) {
      //divide to group by 5
      if  ((i %5 )== 0)
      {
         System.out.print(" ");
      }
      System.out.print( ndoutString[i]);
    }
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
array6 challenfge 6 83
wordmultiple challenge 12 121
Microsoft C++ code failing in executable that worked 9 86
program a usb light to turn on when needed 6 49
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now