func (app *Configurable) Encrypt(parameters map[string]string) interfaces.AppFunction {
	algorithm, ok := parameters[Algorithm]
	if !ok {
		app.lc.Errorf("Could not find '%s' parameter for Encrypt", Algorithm)
		return nil
	}

	secretPath := parameters[SecretPath]
	secretName := parameters[SecretName]
	encryptionKey := parameters[EncryptionKey]

	// SecretPath & SecretName are optional if EncryptionKey specified
	// EncryptionKey is optional if SecretPath & SecretName are specified

	// If EncryptionKey not specified, then SecretPath & SecretName must be specified
	if len(encryptionKey) == 0 && (len(secretPath) == 0 || len(secretName) == 0) {
		app.lc.Errorf("Could not find '%s' or '%s' and '%s' in configuration", EncryptionKey, SecretPath, SecretName)
		return nil
	}

	// SecretPath & SecretName both must be specified it one of them is.
	if (len(secretPath) != 0 && len(secretName) == 0) || (len(secretPath) == 0 && len(secretName) != 0) {
		app.lc.Errorf("'%s' and '%s' both must be set in configuration", SecretPath, SecretName)
		return nil
	}

	initVector, ok := parameters[InitVector]
	if !ok {
		app.lc.Error("Could not find " + InitVector)
		return nil
	}

	transform := transforms.Encryption{
		EncryptionKey:        encryptionKey,
		InitializationVector: initVector,
		SecretPath:           secretPath,
		SecretName:           secretName,
	}

	switch strings.ToLower(algorithm) {
	case EncryptAES:
		return transform.EncryptWithAES
	default:
		app.lc.Errorf(
			"Invalid encryption algorithm '%s'. Must be '%s'",
			algorithm,
			EncryptAES)
		return nil
	}
}
The use of a broken or risky cryptographic algorithm is an unnecessary risk that may result in the exposure of sensitive information.