?
Solved

monoalphabetic cypher

Posted on 2006-11-17
4
Medium Priority
?
420 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 250 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Simple Linear Regression

771 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