Results 1 to 4 of 4
  1. #1
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    10

    Default 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)"?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default

    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

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default

    Quote Originally Posted by Zack View Post
    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)"?
    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

  4. #4
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    10

Similar Threads

  1. Help with compilation
    By santunez in forum New To Java
    Replies: 8
    Last Post: 10-18-2010, 01:31 PM
  2. replaceALL(char oldChar, char newChar) method
    By arson09 in forum New To Java
    Replies: 0
    Last Post: 04-28-2010, 05:48 AM
  3. Difficult compilation
    By pochis40 in forum Java Applets
    Replies: 10
    Last Post: 12-21-2009, 12:35 PM
  4. another compilation prob!!!
    By aiacos88 in forum JCreator
    Replies: 4
    Last Post: 01-27-2009, 03:16 AM
  5. drawing char by char with Graphics
    By diggitydoggz in forum New To Java
    Replies: 5
    Last Post: 12-27-2008, 12:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •