I'm having an issue getting my List<int> Array to output to the console (line 58). The output I get is 'Row = [I@61de33', what I'm trying to get is a list of all the values held within the array in each row respectively.
I'm just not sure what methods I am supposed to use to print this to console or how I should access each row and element directly. Any suggestions to point me in the right direction are welcomed.
The program I'm writing is supposed to take cipher texts, seperate the hex values, then convert to decimal and store in an array list so that I can then XOR their values and try to break the code, hopefully.
I initially wanted to XOR the hex values directly, but couldn't figure out how to do that and found XORing the decimal representation was a lot easier.
I always seem to have this problem when using dynamic arrays. If this were a normal array, I would have been able to loop through and retrieve the elements no problem. I'm not so sure I'm using the arraylists correctly or whether I'm treating them the same as a normal one dimensional array. Any pointer would be great, I've been stuck with this problem all day and haven't been able to make these arrays work for me.
Michael Gordon wrote:I'm not entirely sure how I can iterate through each int Array row of an arraylist tho.
Come on. You know perfectly well how to iterate through an int array. I'm sure of that.
But you seem to think that an int array is somehow different if you got it out of an ArrayList. It isn't. It's just an ordinary int array, so there's nothing stopping you from writing the everyday code to iterate through it and print its entries.
I'm not sure what you meant about "dynamic" and "ordinary" arrays but it looks to me like you're inventing distinctions where none exist. An array is an array no matter how you created it or what objects have references to it.
From your code, it looks like every int array in your list is an array of size one -- what is the purpose of using int arrays if each array has exactly one element? Wouldn't it be better to have a list of integers instead of a list of int arrays?
I appreciate all the pointers guys, but not sure I'm making my intentions clear as I'm getting a bit bogged down with understanding how to move data in and out of the arrays.
Essentially, what I'm trying to achieve is this:
Take one of the ten ciphertext, break it into hex chunks, then add each of those chunks to an array of dynamic size (as the ciphertexts are of differing lengths), then add that row of hex to an int array (as the number of rows are constant) or a dynamic ArrayList if possible to choose 2 random rows when extracting the data, if this is possible? Once I have each ciphertext broken into chunks and in seperate rows of my array, I can then convert each row into ASCII(UTF-8) and output each elements value as a character (putting this into a temp array for display only), once I have this data, I can then XOR one row against data in another row. The XOR data can then be converted back into ASCII (UTF-8) character sets and this should then provide me with with information I can work with. The problem I had with XORing is that I couldn't XOR the hex values ( using xor = valueA ^ valueB) and had to convert them into integers to allow me to do this, which is why I'm trying to figure out how to use and transfer data to and from dynamically sized arrays.
Well, that's the plan anyway, but I've been struggling with how to get these arrays populated and also how to get the data back out of them. I don't fully understand how the dynamic (ArrayList) arrays work in this way and have been going round in circles trying to get it working (I know, I know, welcome to the world of programming right ). Perhaps there is a better way of doing this than the way I'm approaching the problem?
Michael Gordon wrote:I appreciate all the pointers guys, but not sure I'm making my intentions clear as I'm getting a bit bogged down with understanding how to move data in and out of the arrays.
I suspect you're overthinking this.
It seems to me that you have two problems:
2. Cracking the code.
and the two are NOT related.
If those cipher texts are indeed huge numbers, and you want to treat them as such, my suggestion would be to convert them to BigInteger's,
which already have an xor() method, and several methods for display.
How you proceed from there is up to you. I'm no 3rd millenium Raffles.
BTW: I strongly urge you to break up those enormous lines. It makes this thread very hard to read.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
I've shortened the hex values to allow the browser to display the messages in a more readable manner.
The cipher strings are just hex values that represent ASCII characters, I need to break each string down into sets of 2 i.e. a1b2c3d4e5 becomes a1, b2, c3, d4, e5. I think you are right tho, the 2 problems of display and code cracking are not related, think I'm still trying to program in a procedural sense rather than object orientated and the two problems are becoming one (big headache). I had to look up 3rd millenium lol, my programmind design style is probably more like 1st jurassic.
I'll look into BigInteger and see if I can manipulate the data easier with its methods.
So looks like BigInteger is the way to go for xor'ing my data. But I'm still having problems using arrayslists. I have used a multidimensional array to hold my hex data chunks, which seems to work fine, but the problem with using normal arrays is that I need to declare the length of each row before I can use it. This is causing problems because the empty elements are padded with NULL entries. For example, when I try to pass row 0 element 1 AND row 2 element 1 to the xor function, it works fine up until it hits a NULL entry, because BigInteger throws an exception when it is passed a NULL as an argument. I tried to compensate for this by creating an if statement that only performs the xor until it hits a NULL element, when it hits NULL, it should break. I've spent nearly 3 days trying to figure out what should be a simple thing to do, but I'm really struggling.