1

I am making an app in visualstudios's VB to autoinstall the printer in windows. Problem is, that the printer needs a login and pass. I found registry entry, where this is stored, but the password is stored in REG_BINARY format.

Here is how it looks after manually writing the password into printer settings - see UserPass: enter image description here

Please could you tell me how to convert password (in string) into the reg_binary (see attachement - red square)?

The password in this case was 09882 and it has been stored as 98 09 e9 4c c3 24 26 35 14 6f 83 67 8c ec c4 90. Is there any function in VB to convert 09882 into this REG_BINARY format please?

MatSnow
  • 7,357
  • 3
  • 19
  • 31
  • It looks like [DPAPI password encryption in C# and saving into database.Then Decrypting it using a key](https://stackoverflow.com/q/34194223/1115360) could have the information you need. – Andrew Morton Jul 14 '20 at 15:40
  • Thank you! This looks very useful, unfortunately it's in C#. I actually dont know C# language. VB.net only :-( – Miroslav Hrnčíř Jul 15 '20 at 19:27
  • The methods are the same; please see [ProtectedData Class](https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.protecteddata?redirectedfrom=MSDN&view=dotnet-plat-ext-3.1) and choose "VB" in the dropdown to the left of "Bookmark" in the section at the top-right of the page to see what you'd need in VB. – Andrew Morton Jul 15 '20 at 20:07

1 Answers1

2

REG_BINARY means that it is binary data and binary data in .NET is represent by a Byte array. The values you see in RegEdit are the hexadecimal values of the individual bytes, which is a common representation because every byte can be represented by two digits. You need to convert your String to a Byte array and then save it to the Registry like any other data.

How you do that depends on what the application expects. Maybe it is simply converting the text to Bytes based on a specific encoding, e.g. Encoding.ASCII.GetBytes. Maybe it's a hash. You might need to research and/or experiment to find out exactly what's expected.

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46