6 posts in this topic

Posted

I have the following hex string:

[CODE]
010101030300000000000000000000000D00000001000000010000009050AA35B23BDA4B3532F2ABDF4A382E80100000014324686468645602538589053568950000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
[/CODE]

In hex editor it would look like this:

[img]http://i.imgur.com/0ZTghjR.png[/img]

I need to get the data at offset 0x1C - 0x2B (9050AA35B23BDA4B3532F2ABDF4A382E)

I have the following code:
[CODE]
byte[] data = ConvertHexStringToByteArray(Encoding.Default.GetString(hexstring));
MemoryStream input = new MemoryStream(data);
BinaryReader reader = new BinaryReader(input);
reader.ReadBytes(0x1C);
byte[] buffer = reader.ReadBytes(16);
[/CODE]

Share this post


Link to post
Share on other sites

Posted

doesn't that code already does what you need? or did I read the question wrong?

Share this post


Link to post
Share on other sites

Posted

[quote name='francescob' timestamp='1367629531' post='595671484']
doesn't that code already do what you need?
[/quote]
Yes and no. I get the data but need it as hex [color=#282828] (9050AA35B23BDA4B3532F2ABDF4A382E) instead of ANSI ([/color].P

Share this post


Link to post
Share on other sites

Posted

[quote name='DPyro' timestamp='1367629678' post='595671490']
Yes and no. I get the data but need it as hex [color=#282828] (9050AA35B23BDA4B3532F2ABDF4A382E) instead of ANSI ([/color].P

Share this post


Link to post
Share on other sites

Posted

Is this what you want? Quick google.

[url="http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa"]http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa[/url]

Share this post


Link to post
Share on other sites

Posted

[quote name='francescob' timestamp='1367629959' post='595671496']
But what is the output type you need? A string or another byte array? Anyway if the input string is hex you just need to copy twice the bytes/characters from the original hex string to obtain the hex substring. Example: hexstring.SubString(0x1C * 2, 16 * 2);
[/quote]
This makes it way simpler, thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.