MCPcopy Create free account
hub / github.com/smallstep/cli / decodeNonce

Function decodeNonce

command/crypto/nacl/nacl.go:50–66  ·  view source on GitHub ↗

decodeNonce returns the nonce in bytes. If the input has the prefix base64: it will decode the rest using the base64 standard encoding.

(in string)

Source from the content-addressed store, hash-verified

48// decodeNonce returns the nonce in bytes. If the input has the prefix base64:
49// it will decode the rest using the base64 standard encoding.
50func decodeNonce(in string) ([]byte, error) {
51 nonce := []byte(in)
52 switch {
53 case strings.HasPrefix(in, "string:"):
54 return nonce[7:], nil
55 case strings.HasPrefix(in, "base64:"):
56 input := nonce[7:]
57 nonce = make([]byte, base64.StdEncoding.DecodedLen(len(input)))
58 n, err := base64.StdEncoding.Decode(nonce, input)
59 if err != nil {
60 return nil, errors.Wrap(err, "error decoding base64 nonce")
61 }
62 return nonce[:n], nil
63 default:
64 return nonce, nil
65 }
66}

Callers 4

boxOpenActionFunction · 0.85
boxSealActionFunction · 0.85
secretboxOpenActionFunction · 0.85
secretboxSealActionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…