title: Reversible encoding of string to unix filename
body: <p>Is there a way to turn arbitrary user input names into safe filenames with an encoding that is reversible?</p>
  
  <p>I have some data files that belong to entities that users named. Of course, they can do silly things like put invalid filesystem characters in their names.</p>
  
  <p>The two suggestions I see frequently for this are:</p>
  
  <p>A) Base64 encode them</p>
  
  <p>B) Strip illegal characters</p>
  
  <p>Base64 is reversible, but for debugging/introspection, it's really nice when the file names look as much like the names as possible. Just keeps everything more debuggable. Approach B isn't reversible, so the "actual" name has to be stored redundantly anyway, so there's no real value in not just using a uuid or something.</p>
  
  <p>This if specifically for Linux. While this isn't python specific, that's what I'm implementing it in.</p>