Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting char 1

Status
Not open for further replies.

yama

Programmer
Jun 28, 2001
69
SG
Hi,
I have a form(form1.jsp) to get all my form data. then it will submit to form2.jsp. in the form, i have a string that i converted to its ASCII value when i submit this form. the convertion is done using javascript.
the problem is that, when it reaches form2.jsp, how do i convert the string of numbers back to the original string?
anyone please help?
thanks!
 
Just take the int and put it into a char. A char is really just an integer value that represents a unicode character. Since the first 256 characters of unicode corespond directly to ASCII then you should get exactly what you want.
Example:
Code:
int asciiValue = 97; // 'a'
char asciiCharacter = asciiValue;
System.out.println(asciiCharacter);
Careful though, if the value is greater 16-bit you will get a runtime exception. Wushutwist
 
hmm..think this is for a single char, is there any codes for converting a string such as from abc to 979899, then back to abc?
 
sorry...i tried your codes but it returns me this error -->
Incompatible type for =. Explicit cast needed to convert int to char
whats the cause of it?
thanks again!
 
Sorry, you need:
Code:
int asciiValue = 97; // 'a'
char asciiCharacter = (char)asciiValue;
System.out.println(asciiCharacter);
To answer your other question: No. You would need some type of delimiter to separate the characters. If I could ask, why do you need this functionality. Wushutwist
 
oh...'cos i want to some sort of encrypt my password to its ascii value before sending over to other page of my website.
thanks!
 
Why are you trying to encrypt it? Worried about hackers? If so, then hackers could certainly decrypt ascii characters too so I don't see the point in doing so(cause you more trouble than help). Just call your second jsp using POST method should be enough :)

Leon
 
oh...i am using the post method, just that if i didnt encrypt, i am able to get the whole password by using a network sniffer
 
wouldn't you be able to get the password using the network sniffer and decrypting it since it is just ascii codes..?
 
yep, hehe, but i have done some changes to the ascii value before sending it over =)
 
Leon is right, if this is for security purposes then forget it. The problem is that all of your transformations are going to have to be done in javascript and the entire world has access to your javascript source. It would be a trival thing to capture the packets and retrace the steps. If it is security you want then using POST in an SSL connection is good enough. Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top