1

I have seen countless articles and forum posts about this, but sadly none of this could help me.

I simply want to convert the Reg_Binary Value from a key to a string that is human readable.

For example:

enter image description here

And I have tried to convert it via some online converters. And I've written a small program to convert it:

TextboxString.Text = Encoding.UTF8.GetString(Bytes, 12, Bytes.Length - 12);

I have tried every encoding but from all this attempts i only get rubbish.

Online Converter:

enter image description here

Program:

enter image description here

MansNotHot
  • 263
  • 1
  • 3
  • 19
  • have a look into base64 string, namely `Convert.ToBase64String`. Another way will be converting it into hexadecimal string, which is well explained [here](https://stackoverflow.com/questions/311165/how-do-you-convert-a-byte-array-to-a-hexadecimal-string-and-vice-versa) – lamandy Dec 12 '17 at 08:28
  • I think you need to clarify what you expect to see when you say "human readable". – ProgrammingLlama Dec 12 '17 at 08:33
  • A little more research tells me that the encoding seems to be in unicode format, but need to start from byte 12, `Encoding.Unicode.GetString(bytes, 12, bytes.Length-12)`. Comes from [here](https://stackoverflow.com/questions/349410/how-can-i-convert-a-reg-binary-value-from-the-registry-into-a-string-vb-net?rq=1) – lamandy Dec 12 '17 at 08:35
  • @john I have the task from the company to read that out but because of lack of experience i sadly dont know what to expect – MansNotHot Dec 12 '17 at 08:38
  • @lamandy And yes that is very correct. I have done my research but sadly nothing helped jet. And i will take a look at the base64 stuff. – MansNotHot Dec 12 '17 at 08:38
  • I'd go with lamandy's suggestion then, or you could try `BitConverter.ToString(bytes).Replace("-", "")` to get the value as a hexadecimal string similar to how it is presented in the registry. – ProgrammingLlama Dec 12 '17 at 08:39
  • 1
    RegBinary is just arbitrary binary data. Whether it represents a human readable string, and in which encoding, depends on specific key\value. You cannot expect that _any_ RegBinary is a string in some encoding. – Evk Dec 12 '17 at 08:49
  • @Evk What do most RegBinarys represent? – MansNotHot Dec 12 '17 at 08:52
  • They can represent absolutely anything. Like, what most files on your filesystem represent? – Evk Dec 12 '17 at 08:53
  • According to [MSDN](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724884(v=vs.85).aspx), REG_BINARY means binary data in any form so unicode/UTF8 encoding does not make any sense. – lamandy Dec 12 '17 at 08:53
  • @EVk So it simply does not really make sense to try to convert it? – MansNotHot Dec 12 '17 at 08:54
  • 1
    If you don't know anything about what this value represents - then converting using encoding is not what you want. You can convert it to hex string (like is displayed on your first screenshot) if you want to display it in user interface. – Evk Dec 12 '17 at 08:55

0 Answers0