-1

I have string and want to convert it into hexadecimal in C#.net.

This is my Eset Nod32 password:

"12968"

The program saves this password into a binary registry key as:

"50 d6 e6 e9 e4 f0 cd f2 63 64"

How can I do this in C#?

4
  • 1
    What is the rule to map 12968 to 50 d6 e6 e9 e4 f0 cd f2 63 64. I don't see any relation. Commented Jan 25, 2014 at 11:49
  • You have two questions, both of which have been answered already. Please use the search. See Converting string value to hex decimal and How to write Binary Data “as is” to Registry. Commented Jan 25, 2014 at 11:54
  • It's obviously not such a simple relation. There are 80 bits in hex, the input is far smaller. It's probably some kind of hash or something to prevent you from doing precisely the thing you're trying to do. Commented Jan 25, 2014 at 12:14
  • I edited your question based on your comment. Sinds Nod32 does not come with source code, we do not know how it encrypts or hashes your password. This may very well be impossible to reproduce, unless you have a lot of time. Commented Jan 25, 2014 at 12:18

2 Answers 2

0

If you want to get the HEX of each number, for example Hex of 1, Hex of 2 , etc. you can do as below:

string input = "12968";
char[] values = input.ToCharArray();
foreach (char letter in values)
{
    // Get the integral value of the character. 
    int value = Convert.ToInt32(letter);
    // Convert the decimal value to a hexadecimal value in string form. 
    string hexOutput = String.Format("{0:X}", value);
    Console.WriteLine("Hexadecimal value of {0} is {1}", letter, hexOutput);
}

or if you want get the complete string as a float number for example this is the way :

string hexString = "12968";
uint num = uint.Parse(hexString, System.Globalization.NumberStyles.AllowHexSpecifier);

byte[] floatVals = BitConverter.GetBytes(num);
float f = BitConverter.ToSingle(floatVals, 0);
Console.WriteLine("float convert = {0}", f);
Sign up to request clarification or add additional context in comments.

2 Comments

thanks dude . when i use your code . Output is "31 32 39 36 38" for "12968" but . i want convert to this Style "50 d6 e6 e9 e4 f0 cd f2 63 64"
It is not possible to get this value( "50 d6 e6 e9 e4 f0 cd f2 63 64" ) from your input just by converting to hex. with high probability your NOD32 doing some hashing or encryption on your password
0

There can be used following to write binary value to registry

static byte[] GetBytes(string str)
{
    byte[] bytes = new byte[str.Length * sizeof(char)];
    System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
    return bytes;
}

RegistryKey rk = Registry.CurrentUser.CreateSubKey("RegistryValueKindExample");
rk.SetValue("BinaryValue", GetBytes("12968"), RegistryValueKind.Binary);

RegistryKey.SetValue Method

2 Comments

thanks bro . but not this style : "50 d6 e6 e9 e4 f0 cd f2 63 64" yet :(
this is nod32 mapping . my EsetNod32 password is : 12968 . i navigate to Regedit and see "50 d6 e6 e9 e4 f0 cd f2 63 64" value for password . now i want set my New Password . but i have to recreate Value like this.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.