Results 1 to 6 of 6
  1. #1
    Kearnel is offline Member
    Join Date
    Jun 2010
    Posts
    6
    Rep Power
    0

    Default simple porting (from c) problem

    The bottom line is that I'm having trouble porting code because of the c (the language c) stream operator "<<".

    here is the code I'm having trouble with:
    Java Code:
    #define xtime(x)   ((x<<1) ^ (((x>>7) & 1) * 0x1b))
    I really need to know what this code does, Thanks in advance.;)

  2. #2
    JavaHater is offline Senior Member
    Join Date
    Dec 2010
    Posts
    165
    Rep Power
    4

    Default

    there are bit operators

  3. #3
    Jodokus's Avatar
    Jodokus is offline Senior Member
    Join Date
    Jan 2011
    Location
    Amsterdam, the Netherlands
    Posts
    230
    Rep Power
    4

    Default

    Funny guys, those C-programmers!
    I'm no C guru (anymore. It's too long ago, so don't take me too seriously).
    Operatoroverloading is c++ (i.m.h.o.), so JavaHater is right: << is a shift-operator.
    ^ bitwise OR, & bitwise AND, * times. I guess 0x1b is ASCII 27, ESCAPE (00011011).
    Further I'm at a loss: maybe a very concocted way to check if the escape has been pressed.

  4. #4
    Kearnel is offline Member
    Join Date
    Jun 2010
    Posts
    6
    Rep Power
    0

    Default

    No, this code has nothing to do with the keyboard. It's part of the AES encryption cipher.

    Thank you very much. I think this is all I need.:)

  5. #5
    ClickerMonkey is offline Member
    Join Date
    Jan 2011
    Posts
    12
    Rep Power
    0

    Default

    the provided define can be directly translated to java, same operators in java do the same thing.

  6. #6
    Kearnel is offline Member
    Join Date
    Jun 2010
    Posts
    6
    Rep Power
    0

    Default

    Alright, the AES (Rijndael) encryption code I ported from c is not working correctly and I'm wondering of anyone knows where to find AES code in java I can look at.

    My goal is not simply to encrypt data but to learn how the cipher works. Then I want to be able to modify the cipher code and play around with it.

Similar Threads

  1. Replies: 0
    Last Post: 12-28-2010, 10:05 AM
  2. Very simple problem
    By Andyj in forum Java Certification
    Replies: 3
    Last Post: 09-17-2010, 07:49 AM
  3. I have a simple problem
    By o0oNorao0o in forum JCreator
    Replies: 20
    Last Post: 12-25-2009, 09:32 PM
  4. simple line problem / for loop problem
    By helpisontheway in forum New To Java
    Replies: 1
    Last Post: 11-17-2009, 07:12 AM
  5. Porting to a Nokia Device
    By David55 in forum CLDC and MIDP
    Replies: 1
    Last Post: 06-30-2008, 02:44 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
  •