This project needed some refinements (mostly to keep up with go stdlib) so I forked it at v1.1.0 (78f93c1f8b99b0c2f6e7f3d2bdc4993cf87bddff) and modified it slightly. I will keep it here with all original licensing intact - later I may submit PR upstream.
Go wrapper around the Windows Credential Manager API functions.
go get github.com/danieljoos/wincred
See the following examples:
package main
import (
"fmt"
"github.com/danieljoos/wincred"
)
func main() {
cred := wincred.NewGenericCredential("myGoApplication")
cred.CredentialBlob = []byte("my secret")
err := cred.Write()
if err != nil {
fmt.Println(err)
}
}
package main
import (
"fmt"
"github.com/danieljoos/wincred"
)
func main() {
cred, err := wincred.GetGenericCredential("myGoApplication")
if err == nil {
fmt.Println(string(cred.CredentialBlob))
}
}
package main
import (
"fmt"
"github.com/danieljoos/wincred"
)
func main() {
cred, err := wincred.GetGenericCredential("myGoApplication")
if err != nil {
fmt.Println(err)
return
}
cred.Delete()
}
package main
import (
"fmt"
"github.com/danieljoos/wincred"
)
func main() {
creds, err := wincred.List()
if err != nil {
fmt.Println(err)
return
}
for i := range(creds) {
fmt.Println(creds[i].TargetName)
}
}