MCPcopy
hub / github.com/kopia/kopia / EncodeToken

Function EncodeToken

repo/token.go:26–39  ·  view source on GitHub ↗

EncodeToken returns an opaque token that contains the given connection information and optionally the provided password.

(password string, ci blob.ConnectionInfo)

Source from the content-addressed store, hash-verified

24// EncodeToken returns an opaque token that contains the given connection information
25// and optionally the provided password.
26func EncodeToken(password string, ci blob.ConnectionInfo) (string, error) {
27 ti := &tokenInfo{
28 Version: "1",
29 Storage: ci,
30 Password: password,
31 }
32
33 v, err := json.Marshal(ti)
34 if err != nil {
35 return "", errors.Wrap(err, "marshal token")
36 }
37
38 return base64.RawURLEncoding.EncodeToString(v), nil
39}
40
41// DecodeToken decodes the provided token and returns connection info and password if persisted.
42func DecodeToken(token string) (blob.ConnectionInfo, string, error) {

Callers 3

TokenMethod · 0.85

Calls

no outgoing calls