title: MongoDb Field Encryption
body: <p>I am trying to set up a system where I can have a collection of users with encrypted fields and do a search on those fields.</p>
  
  <p>I have tried looking on MongoDB documentation but there is no clear route</p>
  
  <p>I want to have something like this </p>
  
  <pre><code>{
      fname : John,
      lname : Smith,
      ssn : "555-55-5555"
  }
  </code></pre>
  
  <p>look like this </p>
  
  <pre><code>{
      fname : John,
      lname : Smith,
      ssn : "fweiubv3b443hbv4f48h"
  }
  </code></pre>
  
  <p>then be able to do a search like </p>
  
  <pre class="lang-sh prettyprint-override"><code>db.users.find({ssn : "555-55-5555"})
  </code></pre>
  
  <p>The goal is to have a schema run and create the collection </p>
  
  <pre class="lang-js prettyprint-override"><code>db.createCollection("user", {
      "validator": {
         "$jsonSchema": {
             ....
  });
  </code></pre>