caesar cipher

Thread Starter

David_Baratheon

Joined Feb 10, 2012
285
Hi I am looking to make a ceasar cipher on a micro controller and wondered if anyone knew of any guides for using a PIC or some advice on how to go about doing it? Any reading material will be much appreciated. So far all I have is this to go on lol:

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

I will post up progress here and any questions that I have. If anyone has some good reading material to start me off it would be great. Many thanks
 

John P

Joined Oct 14, 2008
2,068
This seems so trivial I wonder if I'm understanding what the problem is. All you do is when a letter comes in, you add or subtract some constant to its ASCII value (with a test for wrapping past A or Z) and there's the result. It would be interesting to have a modern Caesar cipher based on the entire ASCII table--that would have impressed the Romans. (This "zero" you keep mentioning--what is that, please?)
 

Thread Starter

David_Baratheon

Joined Feb 10, 2012
285
A cipher doesn't only mean zero, it also means a code or message:

"
cipher1
ˈsʌɪfə/
noun

noun: cipher; plural noun: ciphers; noun: cypher; plural noun: cyphers
  1. 1.
    a secret or disguised way of writing; a code.
    "he wrote cryptic notes in a cipher"
    synonyms:code, secret writing; More coded message, cryptograph, cryptogram
    "the information may be given in cipher"



    • something written in a code.
      "he came across ciphers written on parchment and concealed in a hollow altar pillar"
      synonyms:code, secret writing; More coded message, cryptograph, cryptogram
      "the information may be given in cipher"




    • a key to a code.


  2. 2.
    dated
    a zero; a figure 0.
    synonyms:zero, nought, nil, 0; More archaicnaught
    "a row of ciphers"



    • a person of no importance, especially one who does the bidding of others and seems to have no will of their own.
      "journalists are not mere interchangeable ciphers in the propaganda battle"
      synonyms:nobody, nonentity, nothing, non-person, unimportant person, person of no account More "he has spent most of his working life as a cipher"
"
 

Thread Starter

David_Baratheon

Joined Feb 10, 2012
285
In terms of what I am unclear on, well firstly I wasn't sure how to interface the PIC to the PC via some form of terminal, so that I could send a letter to be encrypted or decrypted.

Also how can I have a "setting" so that I can show that I wish to encrypt or decrypt the letter, without changing something in the code itself?

And I wasn't sure how to alter the ASCII value of a letter or make a loop at Z.
 

John P

Joined Oct 14, 2008
2,068
I don't think you got my little joke. The point was discussing anything about mathematics with someone from ancient Rome would be difficult because they didn't have zero in their numerical system.

As for the code (code which implements a cipher, hmmm) it might be something like this (for capital letters only, anything else is unchanged)

Rich (BB code):
unsigned char caesarize(unsigned char in_char, unsigned char modifier)
{
  unsigned char out_char;

  if ((in_char >= 'A') && (in_char <= 'Z'))
  {
    out_char = in_char + modifier;
    if (out_char > 'Z')
      return(out_char - 26);
    else if (out_char < 'A')
      return(out_char + 26);
    else
      return(out_char);
  }
  return(in_char);
}
 

shteii01

Joined Feb 19, 2010
4,644
In terms of what I am unclear on, well firstly I wasn't sure how to interface the PIC to the PC via some form of terminal, so that I could send a letter to be encrypted or decrypted.

Also how can I have a "setting" so that I can show that I wish to encrypt or decrypt the letter, without changing something in the code itself?

And I wasn't sure how to alter the ASCII value of a letter or make a loop at Z.
I am pretty sure Microchip, the manufacturer, has provided documents on how to connect PIC to PC. All you have to do is actually read it. But before you can do that, you need to pick the PIC.

There are probably a few HOWTO on youtube as well.
 

THE_RB

Joined Feb 11, 2008
5,438
I don't think you got my little joke. The point was discussing anything about mathematics with someone from ancient Rome would be difficult because they didn't have zero in their numerical system.
...
Sure they did, they used a horizontal line (hyphen char?) for numerical entries where there was no number, like if someone on the list had no goods to tax that day. It just wasn't an official "zero" part of the numerical system. But perfectly functional as a zero, just as it still is today. :)
 

THE_RB

Joined Feb 11, 2008
5,438
Smartie pants. ;)

I often leave the history channel (or other documentary channel) running in the background when working.
 
Top