How can you xor ArrayLists?

Discussion in 'Java' started by cryptogirl, Feb 24, 2006.

  1. cryptogirl

    cryptogirl Guest

    Can you xor Arraylist together? by using the ^ notation. I know the ^
    is for integer representation so if i type cast it to Arraylist would
    that be sufficient?

    Thank you
     
    cryptogirl, Feb 24, 2006
    #1
    1. Advertising

  2. cryptogirl wrote:
    > Can you xor Arraylist together? by using the ^ notation. I know the ^
    > is for integer representation so if i type cast it to Arraylist would
    > that be sufficient?


    What would be the expected output of XORing two ArrayLists?

    robert
     
    Robert Klemme, Feb 24, 2006
    #2
    1. Advertising

  3. cryptogirl

    cryptogirl Guest

    What would be the expected output of XORing two ArrayLists?

    basically i'm implementing WEP dictionary attack for school. And I
    had to store all possible key stream in a hash table and a hash table
    on take in type Object so my keystream were inputted into an Array
    List. I'm going to have my plaint text and convert it to bytes and
    place that into an array list. and then xor both together in order to
    retrieve the cipher text.
     
    cryptogirl, Feb 24, 2006
    #3
  4. cryptogirl

    Chris Uppal Guest

    cryptogirl wrote:

    > basically i'm implementing WEP dictionary attack for school.


    If you are doing anything compute -intensive with collections of primitive
    types (int, byte, etc) then you'd be /far/ better off putting the data into a
    normal int[] or byte[] array.


    > and then xor both together in order to
    > retrieve the cipher text.


    There's no built-in method of computing the elementwise XOR of two ArrayLists,
    nor of doing the same with two byte[] arrays. You'll have to code it yourself
    with a loop.

    -- chris
     
    Chris Uppal, Feb 24, 2006
    #4
  5. cryptogirl

    Roedy Green Guest

    On 24 Feb 2006 08:42:40 -0800, "cryptogirl" <>
    wrote, quoted or indirectly quoted someone who said :

    >Can you xor Arraylist together? by using the ^ notation. I know the ^
    >is for integer representation so if i type cast it to Arraylist would
    >that be sufficient?

    see the SortedArrayList class that allows various merging operations.

    See http://mindprod.com/products1.html#SORTEDARRAYLIST

    this is not APL, Operators work only on primitives.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Feb 24, 2006
    #5
  6. cryptogirl

    Guest

    Actually,

    Why couldn't he do this:

    BigInteger entry1 = new BigInteger(someByteArrayFromKey)
    BigInteger entry2 = new BigInteger(someByteArrayFromOtherKey);

    BigInteger newEntry = entry1.xor(entry2);

    Jobs done and he can use keys of any size

    Christian
    http://christian.bongiorno.org/resume.pdf
     
    , Feb 24, 2006
    #6
  7. cryptogirl

    Chris Uppal Guest

    wrote:

    > BigInteger entry1 = new BigInteger(someByteArrayFromKey)
    > BigInteger entry2 = new BigInteger(someByteArrayFromOtherKey);
    >
    > BigInteger newEntry = entry1.xor(entry2);


    That's a neat idea.

    You would have to be careful about the possibility of leading[*] zeros in the
    data. You could keep track of the size of the input arrays, and ensure that
    the output array is copied and shifted (if necessary) to be the same size as
    the inputs. Another idea would be to force the inputs to have 0x01 and 0x02 in
    position 0, computing the real xor for that position separately, and then stuff
    that into position 0 of the result.

    Overall, sadly, I think it's probably easier to use a loop.

    -- chris
     
    Chris Uppal, Feb 25, 2006
    #7
  8. cryptogirl

    Guest

    Yeah, that's true. In an academic setting like his it won't matter. One
    way of doing this would be to override xor() to assure the proper bit
    maintenance. There is also BitSet -- but it doesn't take a convenient
    byte[] input.
     
    , Feb 26, 2006
    #8
    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. =?Utf-8?B?UG9udGlNYXg=?=

    ArrayList of ArrayLists: How to implement IEnumerable

    =?Utf-8?B?UG9udGlNYXg=?=, Jul 5, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    432
    =?Utf-8?B?UG9udGlNYXg=?=
    Jul 5, 2004
  2. Jim Bancroft
    Replies:
    3
    Views:
    1,882
    Bob Weiner
    May 2, 2005
  3. suma

    how can use xor logic

    suma, May 10, 2006, in forum: Java
    Replies:
    9
    Views:
    4,192
    jmcgill
    May 11, 2006
  4. dataangel

    Why can't I xor strings?

    dataangel, Oct 8, 2004, in forum: Python
    Replies:
    50
    Views:
    1,191
    Andrew Dalke
    Oct 13, 2004
  5. Phil Frost

    Re: Why can't I xor strings?

    Phil Frost, Oct 8, 2004, in forum: Python
    Replies:
    1
    Views:
    328
    Alex Martelli
    Oct 11, 2004
Loading...

Share This Page