ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

binary string to hex string

Solved!
Go to solution

I'm sure there's a very simple solution, but I can't seem to find it anywhere.

 

I have a string that looks like this, "BÑ›c -Ûí3^¥‘¹&¯]" and I want it to look like this, "42D19B630B2DDBED335EA591B926AF5D".

I've tried typecast and unflatten without success. What function should I be using?

0 Kudos
Message 1 of 7
(11,457 Views)
Solution
Accepted by IMSargon

If you just want to see the content in hexadecimal, right-click the indicator and switch to hex display.

 

If you want to format it as a hexadecimal formatted string (2 characters/byte, using characters 0..F exclusively), you could do the following:

 

There are many other ways to do all this. Here's a loop-free version:

 

Message Edited by altenbach on 07-21-2009 10:33 AM
Message 2 of 7
(11,455 Views)

Thanks, your code does do what I need.

 

I should also more clear about what I am doing, so we can see if there are simpler solutions. I am writing a login using a 32 character hex hash read from a file, and comparing this to the output from the OpenG MD5 Digest function.

 

Edit: Thanks, your loop-free version looks like a good solution to me.

Message Edited by IMSargon on 07-21-2009 12:42 PM
0 Kudos
Message 3 of 7
(11,442 Views)
Just select the Display Mode of your string indicator to HEX (Rightclick on it)
0 Kudos
Message 4 of 7
(11,433 Views)

I don't have the openg toolkit installed at the moment. Is the output of the openG MD5 function a hexadecimal formatted string?

 

Do you need to format the string from the file or the output of the MD5?

 

You can go either way: comparing the binary strings or the hexadecimal formatted strings. Same difference.

 

I would store whatever you need to compare in the file so no conversion is needed at all.

0 Kudos
Message 5 of 7
(11,429 Views)
The output of the MD5 function is the binary string. As of now I'm just typing the hashes into the text file, so I couldn't use the binary string in the file. This may change as I come up with a feature to allow users to change their own password.
0 Kudos
Message 6 of 7
(11,426 Views)
Text files contain binary code, but if you open a such file with a text editor it will represent you the contained binary code as ASCII chracters.
0 Kudos
Message 7 of 7
(11,399 Views)