3 Replies - 3147 Views - Last Post: 24 August 2011 - 06:18 PM Rate Topic: -----

#1 Rxanadu   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 30-March 11

hints for Ceasar cipher programs

Posted 24 August 2011 - 05:59 PM

I'll get straight to the point: I have an assignment due in 2 weeks in which I have to create an encipher and decipher program using the Ceasar cipher that will take the string from user input and convert the characters to numbers. I wanted to know if there was a simpler way to do this without using a switch statement to convert all the letters in the alphabet into numbers within the range of 0-25 for the Ceasar cipher. I was thinking of using the ASCII method to circumvent this issue, but it doesn't look like that will work for the way I want to implement this.

I'm not looking for an direct code answer; if you have any general knowledge about what could be useful or any links to other sites for tutorials, that will be fine. I haven't tested any of my code as of yet, but I wanted to know something before I get too deep in the switch statement before I hit a wall.

Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: hints for Ceasar cipher programs

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12680
  • View blog
  • Posts: 45,861
  • Joined: 27-December 08

Re: hints for Ceasar cipher programs

Posted 24 August 2011 - 06:01 PM

Yes. Treat each char like a number and add or subtract 3 to it depending on encryption or decryption. If it goes past the range of values for letters, cycle back around. The ASCII Table is a good place to look for the numeric values.
Was This Post Helpful? 0
  • +
  • -

#3 immeraufdemhund   User is offline

  • D.I.C Regular

Reputation: 79
  • View blog
  • Posts: 495
  • Joined: 29-March 10

Re: hints for Ceasar cipher programs

Posted 24 August 2011 - 06:14 PM

i haven't looked into it much but maybe you can use the String > bytes method for a string.

String sentance = "hello";
Byte[] brokeUP = sentance.getBytes();



don't know if that helps, but it's the first thing i thought of
Was This Post Helpful? 0
  • +
  • -

#4 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: hints for Ceasar cipher programs

Posted 24 August 2011 - 06:18 PM

I have a few "Secret Code tutorials" the first one is Ceasar cipher

http://www.dreaminco...-ceasar-cipher/
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1