Re: Using encryption with special Unicode characters

Discussion in 'Java' started by Roedy Green, Aug 29, 2011.

  1. Roedy Green

    Roedy Green Guest

    On Mon, 29 Aug 2011 16:11:13 +1000, "Qu0ll" <>
    wrote, quoted or indirectly quoted someone who said :

    >raw.getBytes()

    I suspect someday this method will be deprecated.

    raw.getBytes( encoding )

    is what you want since the receiver and sender might not have the same
    default encoding.

    Encryption algorinthms concern themselves with bytes. So you want to
    deal with strings or chars you have to convert them to bytes, encrypt,
    decrypt than turn them back to strings/chars.

    The art of converting String to bytes is called encoding, which has
    nothing to do with encryption.

    See http://mindprod.com/jgloss/encoding.html

    You have to know something about the distribution of your characters
    to choose an optimal encoding. The brute force method is to convert
    your string into a UTF-16 array of byte pairs. However that more than
    doubles the size of the encrypted bytes over optimal.

    You can also compress the string first to get a compact byte string.
    This takes more computing time, but reduces the size of the encrypted
    bytes.
    see http://mindprod.com/jgloss/compression.html
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    The modern conservative is engaged in one of man's oldest exercises in moral philosophy; that is,
    the search for a superior moral justification for selfishness.
    ~ John Kenneth Galbraith (born: 1908-10-15 died: 2006-04-29 at age: 97)
     
    Roedy Green, Aug 29, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Mueller
    Replies:
    3
    Views:
    33,049
    Stefan Mueller
    Jul 23, 2006
  2. Replies:
    2
    Views:
    1,096
    Ingo Menger
    May 31, 2007
  3. rvino
    Replies:
    0
    Views:
    4,661
    rvino
    Aug 14, 2007
  4. Grzegorz ¦liwiñski
    Replies:
    2
    Views:
    967
    Grzegorz ¦liwiñski
    Jan 19, 2011
  5. Mayeul
    Replies:
    0
    Views:
    1,034
    Mayeul
    Aug 29, 2011
Loading...

Share This Page