Exemplo n.º 1
0
func (h Handler) encrypt(k, v string, results chan string) {

	var err error

	if v == empty {
		log.Fatalf("Empty or non-existing environment variable %q", k)
	}

	v, err = h.Method.Encrypt(v)

	if err != nil {
		log.Fatalf("Failed to encrypt secure variable %q: %v", k, err)
	} else if Verbose {
		log.Printf("Encrypted secure variable %q", k)
	}

	results <- strings.Join([]string{h.Prefix, envmap.Join(k, v)}, "")

}
Exemplo n.º 2
0
func (h Handler) decrypt(k, v string, results chan string) {

	var err error

	if strings.HasPrefix(k, h.Prefix) {

		// TODO: use slice instead
		k = strings.Replace(k, h.Prefix, "", 1)
		v, err = h.Method.Decrypt(v)

		if err != nil {
			log.Fatalf("Failed to decrypt secure variable %q: %v", k, err)
		} else if Verbose {
			log.Printf("Decrypted secure variable %q", k)
		}

	}

	results <- envmap.Join(k, v)

}