Results 1 to 4 of 4
Thread: char compilation process
- 09-22-2010, 07:34 AM #1
char compilation process
I got into thinking about security the other night and was thinking about String comparisons; perhaps instead of a String, there could be some class that holds a char[] full of data that represents the String:
Such that:
"Hello" == 'H' + 'e' + 'l' + 'l' + 'o' == {72, 101, 108, 108, 111}
Obviously you could have some kind of compareTo() method that compared to a String by converting it to a char array... (Might be a tad inefficient for security's sake.)
So the question here is... Could this be a more secure way of containing strings; particularly for those applications/applets (server-communication and such) that have sensitive data in them?
And the secondary question is: Do char objects render to some kind of int data on compile-time? That is, if I do a test for "if (a == 'a')", does that compile to "if(a==97)"?
- 09-22-2010, 08:56 AM #2
char is an integer type. And it's a primitive so there's no such thing as "char objects"
Types, Values, and Variables
Lexical Structure
db
- 09-22-2010, 09:00 AM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
The answer is encryption; every not encrypted sequence of chars is open to malicious attacks. Your second question: a char in Java is like an unsigned short in C or C++; 'a' is just symbolic way of saying (char)97. a == 'a' is translated to a == (char)97; evaluation of the expression causes a widening conversion on the rhs so the expression boils down to a == 97.
kind regards,
Jos
- 09-22-2010, 05:46 PM #4
Similar Threads
-
Help with compilation
By santunez in forum New To JavaReplies: 8Last Post: 10-18-2010, 02:31 PM -
replaceALL(char oldChar, char newChar) method
By arson09 in forum New To JavaReplies: 0Last Post: 04-28-2010, 06:48 AM -
Difficult compilation
By pochis40 in forum Java AppletsReplies: 10Last Post: 12-21-2009, 01:35 PM -
another compilation prob!!!
By aiacos88 in forum JCreatorReplies: 4Last Post: 01-27-2009, 04:16 AM -
drawing char by char with Graphics
By diggitydoggz in forum New To JavaReplies: 5Last Post: 12-27-2008, 01:49 PM
Bookmarks