       defers.push d
       encrypt(element.value, (result_string)->
         element.value = result_string.toString()
-        console.log "#{element.name} finished encryption"
         d.resolve()
       )
 

  buffer = collect_sources(elements)
  encryption_source_names = find_names_for(form, elements)
  wipe_source_fields(values, encryption_source_names)
  write_target(buffer, values)
  callback(values)

collect_sources = (elements)->
  buffer = ""

    if contains(element.name, encryption_source_names)
      element.value = ""

write_target = (buffer, data, callback)->
  target_name = $("*[data-encrypt-target]").attr("name")
  if target_name
    encrypt(buffer, (result_string) ->
      for element in data
        if element.name == target_name
          element.value = result_string.toString()
      callback(data)
    )
  else
    console.error("No target defined")
