Skip to content

Go wrapper around the Windows Credential Manager API functions

License

Notifications You must be signed in to change notification settings

keys-pub/wincred

 
 

Repository files navigation

wincred

Go wrapper around the Windows Credential Manager API functions.

Build status GoDoc

Installation

go get github.com/danieljoos/wincred

Usage

See the following examples:

Create and store a new generic credential object

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

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

Remove a credential object

package main

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

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

List all available credentials

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

About

Go wrapper around the Windows Credential Manager API functions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%