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.
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)