Caesar Cipher

Pages: 12
we all know that Caeasar Cipher accepts only alphabets from A-Z and its key is n<=26.
Caesar Cipher does not accept numbers.
last night , I found an exercise which said that this code a certain code is encoded using Caesar Cipher **BUT** this code is a **composed of numbers and alphabets** like for example "69bc". This surprised me because as I said :" **Caesar Cipher does not accept numbers**" but I see a code with numbers and not only alphabets and this code must be decrypted to plain text.

the solution does not interest me . I am very very interested on and my questions are :
**2)how a code, which is composed from numbers and alphabets, is created using Caesar Cipher encoding???
1)how to decrypt a code (which is encoded using Ceasar Cipher and composed not only from alphabets but numbers like for example "69dc" )if we know that Cisaer Cipher does not accept numbers????????
**
any help would be appreciated
closed account (Dy7SLyTq)
 we all know that Caeasar Cipher accepts only alphabets from A-Z and its key is n<=26.

what are you talking about? it accepts any character. Ceaser was Roman, which was a completely different alphabet, so he wouldnt use it for english. i dont know where you got that from. most modern ceaser ciphers extract the ascii value, and then replace the current character with that character + the offset. ill put an example after i finish this
http://www.cplusplus.com/articles/9hvU7k9E/
might be something interesting to read.
closed account (Dy7SLyTq)
 ``123456789101112131415161718192021222324252627282930313233`` ``````#include #include using std:: cout; using std:: endl; using std:: cin; using std::string; string Encrypt(string, int); int main(int argc, char *argv[]) { string Source; int Key; cout<<"Source: "; getline(cin, Source); cout<<"Key: "; cin>> Key; cout<<"Encrypted: "<< Encrypt(Source, Key) << endl; } string Encrypt(string Source, int Key) { string Crypted = Source; for(int Current = 0; Current < Source.length(); Current++) Crypted[Current] += Key; return Crypted; }``````

 ``` dtscode@dtscode-Latitude-E6410:~/Desktop\$ gcc*/bin/g++ -std=c++11 encrypt.cpp -o encrypt dtscode@dtscode-Latitude-E6410:~/Desktop\$ ./encrypt Source: My code is 42 Key: 7 Encrypted: T�'jvkl'pz';9 ```

its not perfect but it gets the idea across.i might add some cool features to unwind tonite
Last edited on
I thought caeser ciphers if they go past the last character they loop back to the start. Hence the shift.
Also you should make the key the modulus of 26 ( if its an English alphabet )

say we have

"Zebra" with a 15 key

That should be "Otqgp" or even "otqgp" without any uppercase allowed.
Last edited on
DTSCode , Caesar Cipher does not accept numbers , it accepts only alphabets from A-Z and the key is n<=26. , but prove me wrong

www.math.uic.edu/CryptoClubProject/CCpacket.pdf‎

www.nku.edu/.../092HNR304%20section%202%20caesar%20ciphers.pd

en.wikipedia.org/wiki/Caesar_cipher‎

can you decrypt a code in Caesar Cipher where the code is a mixture of numbers and alphabets and where the key is greater than 26??

for example

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 0 1 2 3 4 5 6 7 8 9 ; \ \ . , < , %

the key now is not 26 but 43 and there is not only alphabets from a-z but also numbers and other Ascii characters

so is it possible to decrypt a code , say for example 69bc56dg , using Caesar Cipher with a key greater than 26??? if so , then show me how? with details and examples and I want you to give me the source of your knowledge about how decrypt a code using Caesar Cipher with a key that is greater than 26

You can. Just use a container to store the accepted characters. Then shift the character in that container. Also the key can be ANY number. If the new character's is a size of 42 then say we have 84

That means

 ``12`` ``````while( key > size ) key -= size;``````

Another method is

`key %= size;`

To give the actual number of shifts that make a difference.
Last edited on
@strongard63
Your premise is wrong and you are being very aggressive about it. Caesar cipher is a shift cipher. In instructional contexts, it will be implemented the way Caesar did it: restricting the alphabet. You have to realize that in crypto, the word "alphabet" does not imply letters only -- it means the set of symbols used. There is no compelling reason to need to prove to you that a Caesar cipher can be applied to alphabets other than the letters A..Z. The alphabet can be any set of symbols you want, including spaces and numbers and punctuation, so long as it has a distinct lexographic ordering.

@all
Yes, the shift is a modulo shift, otherwise you would have information loss, since input alphabet equals output alphabet.
The usual way to "accept" input that can't be encoded with a Caesar cipher is to pass it through the encoding and decoding process unchanged.

@DTSCode - That's not a Caesar cipher.
closed account (Dy7SLyTq)
@cire: i thought it just shifted the letters? would you be willing to share an example?
 @cire: i thought it just shifted the letters? would you be willing to share an example?

There are plenty of explanations and examples that can be found via google.

http://en.wikipedia.org/wiki/Caesar_cipher
closed account (Dy7SLyTq)
and thats not what i did? i googled before posting to make sure i was right and thought i had implemented it right?
 and thats not what i did?

No, it's not.

 Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW

http://ideone.com/Yf8s57

DTSCode. You shifted them right. But when they were past the last index you kept going instead of looping back to the start then continue to increment.

*edit
Just look at your output anyways. This is not a-z which is the alphabet he is using:

 T�'jvkl'pz';9

I showed you what it was supposed to look like earlier if we had zebra as source:
 otqgp
( Most of the times the alphabet is all lowercase so people don't know when a sentence ends and other reasons we use capital letters. )

*edit here's a simple version of a caesar cipher taking only a-z

 ``1234567891011121314151617181920212223242526272829`` ``````#include #include void encrypt( std::string &iostr , int key ) { key %= 26; int ch; for( auto &it : iostr ) { ch = tolower(it) + key; if( ch > 'z' ) ch -= 26; it = ch; } } int main() { std::string source = "zebra"; int key = 15; std::cout << source << std::endl; encrypt( source , key ); std::cout << source << std::endl; return 0; }`````` ```zebra otqgp Process returned 0 (0x0) execution time : 0.214 s Press any key to continue. ```
Last edited on
Your premise is wrong and you are being very aggressive about it

agressive?? not at all

Your premise is wrong , this is why I am here to get corrected

most importantly , you said:"restricting the alphabet. Yo.......... it has a distinct lexographic ordering."

so if it can accepts many characters so can you tell me why the key of Caesar Cipher is restricted only to 26 letters of alphabets from a-z ?????
for example in this site :

http://rosettacode.org/wiki/Caesar_cipher
it says there is only from 1 to 25 keys not more but you said the contrary that it can accepts more , you do not see that you contradict WIKI

if it can accept more than 26 keyes it means that all what is wriiten in WIKIpedia is wrong

Normally the Cipher uses letters, but you could use numbers if you wanted. There is nothing that says it can be only letters. You could easily do a series of 1 to 26 and then set a key and it would shift the 26 numbers just like it would the letters. From what I'm reading on the wiki page cire posted, it just looks like you are doing about the same as just swapping array elements (though I may be looking at it too simply and misunderstanding the article).

The cipher is talking about keys of 26 because A-Z is 26 letters so if they key is over 26 you are doing more work than needed as 27 would be the same as a key of 1. It depends on what you are wanting to shift and what key you want to use. It doesn't restrict you to just alphabet though.

For example, say you had a string that was "A-Z0-9" (just to save space of typing all 26 letters and 10 numbers. Now that is 36 characters (26 letters and 10 numbers) so the key is n<= 36 to shift the 36 characters. What I'm trying to get at is that you set the restrictions, not the cipher.
Last edited on by closed account z6A9GNh0
 Normally the Cipher uses letters, but you could use numbers if you wanted. There is nothing that says it can be only letters.

Assuming by the Cipher you mean the caesar cipher, these statements are not correct. The very definition of said cipher precludes the encoding of numbers or other non-letter characters. Of course, it is trivial to whip up something which can do that based on the more general idea of a shift cipher which class the caesar cipher belongs to.
@cire
No, by the Cipher I was meaning shift ciphers. I read the Caesar Cipher wikipedia link and know it has to be A-Z. Sorry, it was late and wasn't fully with it. My point was that wherever he saw numbers being used in a Caesar Cipher means the user did what I mentioned, just wrote a shift cipher and was falsely calling it a Caesar Cipher. There are variants of it (again according to the wiki link), as Augustus Caesar wouldn't loop so X could be AA or such.

Kind of funny that a Mafia boss used a cipher that used numbers to represent letters , but guess it didn't work so well since he was caught.
Why can a caesar cipher not have numbers? You guys are forgetting there are more languages than just ENGLISH. A lot of languages have different alphabets. Also why can someone not create their own "alphabet" that contains letters, symbols , and numbers? Also technically the caesar cipher is a shift of 3 characters to the right so if you use English it is like this

 ``` Position: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 English: 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 Caesar: d e f g h i j k l m n o p q r s t u v w x y z a b c```
ok , then , I can say that Caesar Cipher accepts all type of characters either numbers , letters or other .

but if I have a problem concerning it in the future , then , I will open the topic again
Pages: 12