Data Conversion

B

Brad Markisohn

I've been brute forcing a conversion of binary data in a byte array into
ASCII encrypted hex (2 chars = 1 byte). Is there a formatting scheme that
will allow me to do this? Here's a snipet of the code I've been using:

For Count = 0 To myBuffer.Ubound(0)

If Len(Hex(myBuffer(Count))) < 2 Then

ByteValue = "0" & Hex(myBuffer(Count))

Else

ByteValue = Hex(ReadBuffer(Count))

End If

DisplayString.Append(ByteValue)

Next Count
 
A

Armin Zingler

Brad Markisohn said:
I've been brute forcing a conversion of binary data in a byte array
into ASCII encrypted hex (2 chars = 1 byte). Is there a formatting
scheme that will allow me to do this? Here's a snipet of the code

Formatting scheme?
I've been using:

For Count = 0 To myBuffer.Ubound(0)

If Len(Hex(myBuffer(Count))) < 2 Then

ByteValue = "0" & Hex(myBuffer(Count))

Else

ByteValue = Hex(ReadBuffer(Count))

End If

DisplayString.Append(ByteValue)

Next Count

I would write:

For Count = 0 To myBuffer.Ubound(0)
DisplayString.Append(myBuffer(Count).ToString("X2")
Next Count

Does this help?


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
G

Gary Chang

Hi Brad,

Thanks for posting in the community.

Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
P

Peter Huang

Hi Brad,

Thanks for posting in the community.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you want to convert a byte array
into a string, where each byte will be convert into two chars.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I agree with Armin's suggestion. Also what do you mean by the "Formatting
scheme", if you have any concern on this issue ,please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top