title: Symfony: How to encrypt/decrypt route parameters automatically?
body: <p>I'd like to <strong>en-/decrypt parameters</strong> <em>(e.g. IDs)</em> in the URL/route <strong>automatically</strong>, example:</p>
  
  <p><code>domain.com/item/show/1</code> should look like <code>domain.com/item/show/uj7hs2</code>.</p>
  
  <p><strong>Current (pseudo-)code</strong></p>
  
  <pre><code>public function myControllerFunctionAction() {
      // ...
      $id = $this-&gt;get('my.crypt')-&gt;encrypt($item-&gt;getId());
      return $this-&gt;redirectToRoute('routeTo_myOtherControllerAction', array('id' =&gt; $id));
  }
  
  public function myOtherControllerFunctionAction($id) {
      $id = $this-&gt;get('my.crypt')-&gt;decrypt($id); // decrypt
  
      $item = $this-&gt;get('my.repository')-&gt;find($id);
      // ...
  }
  </code></pre>
  
  <p>I'd like to <strong>avoid manually en-/decrypting</strong>.</p>
  
  <p>Something like this would be perfect:</p>
  
  <pre><code># routing.yml
  routeTo_myOtherControllerAction:
      path:     /item/show/{id}
      defaults: { _controller: appBundle:Items:show }
      options:
          crypt_auto: true
          crypt_method: %default_crypt_method%
  </code></pre>
  
  <p>I couldn't find any other solution than my service yet. Any ideas?</p>
  
  <p>Thanks in advance!</p>