# Thread: I need help on what I think is a Caesar cipher......

1. ## I need help on what I think is a Caesar cipher......

Hello , I have a problem with my assignment problem , which I think is a caesar cipher

The objective of my program is to encrypt/decrypt

The program will take in a user in put as a keyword
The letters of the alphabets are arranged starting with the keyword and followed by the remaining letters in reverse order
The keyword will not have recurring letters.

Using tiger as a keyword :

 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z T I G E R Z Y X W V U S Q P O N M L K J H F D C B A

I am supposed to use that to encrypt/decrypt messages
But I am unsure of the logic , what will I use to arrange the letters ? what will I use to eliminate recurring alphabets.

Thank you for the time.

2. Announcements - General Programming Boards

This site expects the posters to write some code at least; read the URL above.

Note: I am only a C programmer; so, I can not even help you if I wanted to do so.
Note: If you already know how to sort array you might wish to think of the problem as an array sorting problem.

C, C++ Programming Tutorials - Cprogramming.com

Tim S.

3. Perhaps an array of structs where each struct holds an encrypt char and a decrypt char. For example, your first struct in the array would contain 'A' for the decrypt char and 'T' for the encrypt char, and so on and so forth. As far as not allowing duplicate letters in the keyword, that's a matter of validating the user input; read the chars into a map, and if if the insertion fails (since maps dont allow duplicate keys) you know you have a duplicate letter. A map is also a good choice as an alternative to the encrypt/decrypt array i described previously. Obviously, you and your professor
Know which c++ features you're allowed to use, so i leave it to you to pick the solution that meets those requirements

4. Do you know the length of the keyword? This is not a Caeser Cipher, that would be a simple substitution cipher eg , a = z, b = y, c = x etc. the problem is a hybrid and according to your rules you should basically ignore the substitution part of the cipher becuase once you have the keyword then the rest will follow. So given that computers are rather useful in repeating millions of mindless tasks, , your attack in this case should be to simply test sequences of abcde,(depending on what you think key length is..) over the whole ciphertext, then bcdef, then cdefg, etc etc, its a loop the loop, if the output reveals a sensible word... like t ig e r ' then you can start making assumptions, to be honest, if the output revealed a good word as long as 'tiger' then its a fair safe bet you have it cracked.

But of course, you will need some code to do these test to start with.. so best get cracking eh ;-> show some effort and then you will get some good advice back.

5. or maybe thats the other way around.. its a while since i looked at any
cryptohydroponic analysis

6. rogster001, this IS a Caeser Cipher.

That task is not hard. You should use 2 arrays of chars:
Code:
```char plaintext[26];
char cypher[26];```
Fill the first one with A-Z.
Start to fill the second one by adding the keyword TIGER. Then append letters Z-A one by one, checking if they appear in keyword.

7. Hello , thank you for your input , everyone .

The cipher key is user defined , which means that it could be 26 letters long , as long as does not have any recurring letters.

I have thought of the logic of this question, but I have one problem :

Can I shift text around ?

I am planning to make my program check for matching letters between the text array and my cipher key , then bringing the cipher key to the front , and the rest at the back

For example :

using tiger as an example

Text array='Z','Y','X','W','V','U','T','S','R','Q','P', 'O','N','M','L','K','J','I','H','G','F','E','D','C ','B','A'

The program will search for T,I,G,E,R and bring it to the front.

I will then shift the others to the back.

Is there any C++ function that can aid me in this ?

To any mods : I am not requesting for codes , good sirs , I am here just to ask questions .....

8. You can have two arrays like

Code:
```char plaintext[26];
char ciphertext[26];```
plaintext containing all alphabets...u could write a loop and use ASCII values...

Have a string to take the keyword

First add all alphabets of keyword to ciphertext array...
then write a nested loop

First one to traverse from index 25 to 0 of plaintext...
Second to check if the index of plaintext is present in the keyword..set a flag if present...on exit of this loop u an check the flag and set the value for ciphertext if the flag is not set....

9. I don't agree that this is a classic ceaser cipher, as i said it is a hybrid, an evolution of the classic idea in a rudimentary attempt at greater security, which am sure is just one of the evolutions and refinements seen in the history of ciphers, but the point is moot.