nit for the future: you could use a match statement here
encoding match {
  case "hash" => ...
  ...
}