MCPcopy Create free account
hub / github.com/AdRoll/baker / parseConf

Method parseConf

filter/crypt.go:113–136  ·  view source on GitHub ↗
(conf map[string]string)

Source from the content-addressed store, hash-verified

111}
112
113func (alg *cryptFernet) parseConf(conf map[string]string) error {
114 keyStr, ok := conf["Key"]
115 if !ok {
116 return fmt.Errorf(`can't find "Key" conf for Fernet algorithm`)
117 }
118
119 key, err := fernet.DecodeKey(keyStr)
120 if err != nil {
121 return err
122 }
123 alg.key = key
124
125 ttl := 0
126 ttlStr, ok := conf["TTL"]
127 if ok {
128 ttl, err = strconv.Atoi(ttlStr)
129 if err != nil {
130 return fmt.Errorf(`can't parse "TTL" as seconds: %v`, err)
131 }
132 }
133 alg.ttl = time.Duration(ttl) * time.Second
134
135 return err
136}
137
138func (alg *cryptFernet) encrypt(msg []byte) ([]byte, error) {
139 return fernet.EncryptAndSign(msg, alg.key)

Callers

nothing calls this directly

Calls 1

DurationMethod · 0.65

Tested by

no test coverage detected