Computer Science Canada encrypting codes |
Author: | uknowhoiam [ Thu Dec 18, 2008 8:27 pm ] | ||||
Post subject: | encrypting codes | ||||
my question that i have to answer is this . Write a program to read in a phrase and encrypt this phrase using a basic ?Caesar? cipher. Caesar realized that messages could be hidden in encrypted text. He sent messages by shifting characters to encrypt the messages contents. Your program will read in a phrase and encrypt the phrase. The user will choose the character shift or a random number can be chosen for the character shift (between 1 and 25) .The original and encrypted phrases must be printed out. This is what i got so far..
my problem is that, when encrypt is over lowercase z then it goes further in the ascii code (w/e is after z) what i want is that i want it to go to capital A instead of going further im stuck ![]() ![]() Mod Edit: Remember to use syntax tags! Thanks ![]()
|
Author: | Insectoid [ Thu Dec 18, 2008 8:57 pm ] |
Post subject: | RE:encrypting codes |
perhaps 'if ord (letter) > ord(z) then however many characters it is past z + A'?. That made sense to me, but I doubt I explained it well. You need to find out how far a letter is past ascii z and then add that much -1 to ascii A. So say it is at ascii 124, it is 2 more than z, so add 2-1 to A, to get a capital B. Remember that there is a few ascii characters between Z and a. Oh, and Turing uses ansii (not that it makes too much difference). |
Author: | uknowhoiam [ Fri Dec 19, 2008 3:53 pm ] |
Post subject: | RE:encrypting codes |
ugh i handed my program in so now it doesnt matter if i edit it, but my teacher said it doesnt really matter if i get this question wrong cuz it is really hard, she wont cut marks off |
Author: | syntax_error [ Fri Dec 19, 2008 8:34 pm ] |
Post subject: | RE:encrypting codes |
Now you have 2 weeks(ish) to fix it, and learn if you wish to. |
Author: | Tyr_God_Of_War [ Fri Dec 19, 2008 9:10 pm ] | ||
Post subject: | Re: encrypting codes | ||
Would that work? |
Author: | SNIPERDUDE [ Sat Dec 20, 2008 10:46 am ] | ||||||||
Post subject: | Re: encrypting codes | ||||||||
Tyr_God_Of_War @ December 19th 2008 wrote:
Would that work? You could of just as easily made this line
this
for future reference. You just put the character before the equal so you don't have to repeat the variable name. So for example multiplying the variable Test by 3 would look like this:
|