Results 1 to 2 of 2
  1. #1
    divyanshu023 is offline Member
    Join Date
    Sep 2009
    Posts
    2
    Rep Power
    0

    Default XOR operation on bytes

    I want to do a XOR operation on bytes.

    I am using two bytes variable whose size is 16 bytes each

    e.g byte[] buf = new byte[16]
    byte[] buf1 = new byte[16]

    can i do a XOR operation on the two byte variables

    a statement like buf = buf ^ buf1 gives me an error.do i need to do XOR opearation on individual bytes??

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

    Default

    Yes, each byte.

    Java Code:
    for( int i = 0; i < buf.length; i++ )
       buf[i] = (byte)(buf[i] ^ buf1[i]);
    My Hobby Project: LegacyClone

Similar Threads

  1. Replies: 24
    Last Post: 12-03-2009, 10:58 PM
  2. Bit Wise operation: shifting
    By rueter in forum New To Java
    Replies: 1
    Last Post: 06-27-2009, 06:51 AM
  3. Replies: 6
    Last Post: 04-20-2009, 01:46 AM
  4. [Beginner]Eclipse RCP Undo/redo operation
    By pollux in forum Eclipse
    Replies: 2
    Last Post: 02-18-2009, 06:39 PM
  5. Frame close operation
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-21-2007, 08:39 AM

Posting Permissions

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