Solved

monoalphabetic cypher

Posted on 2006-11-17
4
370 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

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.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

21 Experts available now in Live!

Get 1:1 Help Now