i am new to this kind of programming. please help me,.

i got an IP address (32bits) & 3 int (32 X 3 = 96bits) totaling for 128bits i.e., 16bytes.

my problem here is, how to club them all together to create a 16byte string.

please help. thanks in advance

Recommended Answers

All 5 Replies

cast your IP address as a string if it isn't already. Cast your ints as Int objects, then you'll just need to concatenate them:

Integer one = integerone //your initial value;
Integer two = integertwo
Integer three = integerthree
String myChunk = ipstring.concat(all of your Ints to strings);

Is that what you are asking?

hi eggmatters, thanks for your reply.

but that is not what i am looking for..

this involves some kind of biwise operation.

everything together should become a 16byte string.

hi eggmatters, thanks for your reply.

but that is not what i am looking for..

this involves some kind of biwise operation.

everything together should become a 16byte string.

Ok, you've lost me there. you are creating strings. Strings are arrays of characters. Characters are bits. Ultimately, anything you code is a 'bitwise' operation. The term 'bitwise operation' explicitly means a comparison of two strings of bytes. Namely XOR and XAND.
Could you be more specific about how your data is typed? is it all character arrays? is it that you need to convert your ints to bytes? Do you want to convert all of your data into a hexidecimal string? Do you have sample code or some type of data structure that you can provide?

By bit operation I think he literally means an operation that directly operates on/manipulates bits. Although the only way I see to do this is to set aside an array of that many bits (via creating an array of 4 integers, which are 32 bits each in Java), then by using some specific operation such as OR (where each int in the array was initialized to 0). Probably not the solution he wants though.

i think the issue here is how to create a 16byte string.

String testString = "quickbrownfoxjum";

this forms a 16byte string.
he is trying to club 32bit ip number & other 3 integers together a string like the above said.

16 letters in the string should represent all the 4 values.

i think, this is what he is looking for....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.