View Full Version : Cryptography Encrypt/Decrypt
terek
11-15-2004, 04:09 PM
I need some help in somehow writing a script, in either html or any other porgram, that will take something i wrote and encrypt it using the worlds most basic encryption style. What i want it to do is look at every single letter and change each letter to the letter that comes directly after it in the alphabet.
Then i send the message to someone else and they will have the same program. They will put this jumbled message into the same program and hit "decrypt." When that happens i want the program/website to go through and look at the letter and change them to the letter previous to it in the alphabet.
I know a little about cryptography and a little about scripting but it has been to long and i need some help. This is for a few games(text based RPG's) and some other undisclosed reasons.(in case there are any teachers out there reading this) ;)
Can someone Helps ME!!?
How are you planning on sending it?
Since I guess yo dont have access to a PHP server, I would Javascript would be your best bet for a web language. If its not really web related, probably something in c or c++ or something.
Javascript, you could make a page that enables you to type in a box, click 'encrypt', then instantly receive the encrypted message in another box.
Could also give it a decrypt button to decrypt messages copy/pasted into the input box.
Blue Cat Buxton
11-16-2004, 02:39 AM
You could do this quite easily with the ASCII codes -
the program would basically
1. get the length of the input
2. loop through each letter, getting the current ASCII code
3. check if the letter is an A or a Z
3. if not add a number to the code (or deduct if decoding)
4. if z and coding make a / if z and decoding make a
5. save new letter to output string.
Use c++ or PHP depending on where you are going to deploy the program
terek
11-16-2004, 02:29 PM
Its gonna be embedded in html. it wont end up on the internet but itll be just something i can send to my friends. and yes i have created a few php websites of my own. in total i think ive created 3 or 4 php sites.
I would still need the help in getting it going though. I dont know how to write any type of scripting. I have very basic html but not java or anything else. im borrowing a book from one of my teachers but they are only letting me borrow it for one night. so whatever help you could give would be great.
Definetely javascript then - I think c++ would be a bit much.
javascript is not java, dont get the two confused. see www.w3schools.com for a javascript guide, as well as all the html guide you will need.
Blue Cat Buxton
11-17-2004, 02:34 AM
How did you get on?
terek
11-17-2004, 06:09 PM
one of my teachers told me about using strings. stuff like left, mid, and right strings. i dnt know waht he meant but thats what i gotta try and do. can you help me?
Xander
11-18-2004, 04:58 AM
I've never done much javascripting before but I took a whack at making an encrypter/decrypter like you describe above. Didn't take long, most frustrating was trying to find the functions for getting the character codes and reverse.
If you want to learn javascript the best way is just by having a crack at it. r2d2 posted a good link (w3schools) which is what I used.
Function for returning the actual character from ascii character
function charFromCharCode (charCode) {
return unescape('%' + charCode.toString(16));
}
Text = "hello world";
//below returns 7
acode = charCodeAt(1);
// line below returns h backs
achar = charFromCharCode(acode);
terek
11-18-2004, 02:57 PM
that code means nothign to me because i dont know what ascii is or how to use it. i apreciate your help and i want you to continue to help me. i am trying to learn javascript, i just need to get a book now. ive done some stuff but it is hard for me to learn this stuff alone. i need others to explain it to me.
my teacher also said something to the effect of char strings. he said make the string look for the character, add 1(changes the character to the one next in the alphabet) and then return it to you. i dont know how to do this nor do i know the numbers that corrispoond with each character.
EDIT:
oh can you change my rank to something like "Jedi Master." i see yours is changed r2d2 i just thought maybe you had admin access.
Blue Cat Buxton
11-19-2004, 02:44 AM
that code means nothign to me because i dont know what ascii is or how to use it. i apreciate your help and i want you to continue to help me. i am trying to learn javascript, i just need to get a book now. ive done some stuff but it is hard for me to learn this stuff alone. i need others to explain it to me.
ascii is the numerical standard for representing letters. A=65, b=66 etc. you can see them all at www.asciitable.com
my teacher also said something to the effect of char strings. he said make the string look for the character, add 1(changes the character to the one next in the alphabet) and then return it to you. i dont know how to do this nor do i know the numbers that corrispoond with each character.
Now you do!
Take it little steps at a time and you should be able to solve this :)
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.