3

I'm using Windows Credential Manager to store database credentials for my application built in Go through the wincred package.

It works for retrieving passwords for credentials created by the package itself, however for credentials created straight through Windows Credential Manager, the package is adding "spaces" (byte '0') between the characters when converting from []byte to string.

//Retrieve a credential object
package main

import (
    "fmt"
    "github.com/danieljoos/wincred"
)

func main() {
    cred, err := wincred.GetGenericCredential("myGoApplication")
    if err == nil {
        fmt.Println(string(cred.CredentialBlob))
    }
} 

In the example above I've set the password for "myGoApplication" as 123456, but it retrieves as

1 2 3 4 5 6

The []byte representation is

[49 0 50 0 51 0 52 0 53 0 54 0]

I'm wondering if anyone has any idea on what might be causing this issue.

Jose Bagatelli
  • 1,367
  • 1
  • 15
  • 32

2 Answers2

0

The returned result looks like UTF-16.

Is wincred's UTF-16 conversion working properly? Good to check with the authors.

Wojciech Kaczmarek
  • 2,173
  • 4
  • 23
  • 40
0

As a workaround I'm removing the null bytes which work's for my purposes for the time being but this is unlikely to be the right solution.

bytes.Replace(myBytes, []byte("\000"), nil, -1)
Jose Bagatelli
  • 1,367
  • 1
  • 15
  • 32