func NewStringVar(input string) StringVar {
	return StringVar(fmt.Sprintf(`${%s}`, input))
}
NewStringVar returns a new string variable that consists of wrapping the provided string within a string variable
format. It does so by prepending "${" and appending "}" to the input. This string variable form is compatible with
the default string variable form used by the org.apache.commons.lang3.text.StrSubstitutor library.
package encryptedconfigvalue
import (
	"fmt"
	"regexp"
	"strings"
)
const stringVarEncryptedValRegexpStr = `\${enc:[^}]+}`
var stringVarEncryptedValueRegexp = regexp.MustCompile(stringVarEncryptedValRegexpStr)
type StringVar string
func ContainsEncryptedConfigValueStringVars(input []byte) bool {
	return stringVarEncryptedValueRegexp.Match(input)
}
func DecryptAllEncryptedValueStringVars(input []byte, key KeyWithType) []byte {
	return replaceAllStringVars(input, func(raw []byte) ([]byte, bool) {
		encryptedVal, err := NewEncryptedValue(string(raw))
		if err != nil {
			return raw, true
		}
		decrypted, err := encryptedVal.Decrypt(key)
		if err != nil {
			return raw, true
		}
		return []byte(decrypted), false
	})
}
func NormalizeEncryptedValueStringVars(input []byte, key KeyWithType, normalized map[string]EncryptedValue) []byte {
	return replaceAllStringVars(input, func(raw []byte) ([]byte, bool) {
		encryptedVal, err := NewEncryptedValue(string(raw))
		if err != nil {
			return raw, true
		}
		decrypted, err := encryptedVal.Decrypt(key)
		if err != nil {
			return raw, true
		}
		plaintext := decrypted
		if sub, present := normalized[plaintext]; present {
			return []byte(sub.ToSerializable()), true
		}
		normalized[plaintext] = encryptedVal
		return raw, true
	})
}
func DecryptSingleEncryptedValueStringVarString(input string, key KeyWithType) (string, error) {
	return DecryptSingleEncryptedValueStringVar(StringVar(input), key)
}
func DecryptSingleEncryptedValueStringVar(input StringVar, key KeyWithType) (string, error) {
	contents, err := input.Contents()
	if err != nil {
		return "", err
	}
	ev, err := NewEncryptedValue(contents)
	if err != nil {
		return "", err
	}
	return ev.Decrypt(key)
}