title: Licensing system for client side code web application
body: <p>I have a client-side web application running on SharePoint Site Collection, each site collection has it's own unique id. I want to use a licensing process to lock the app to a site collection.</p>
  
  <p>This is the challenge-response process I'm trying to implement: </p>
  
  <ul>
  <li>User prompted to generate <code>challenge code</code></li>
  <li><code>challenge code</code> is <code>site_collection_id</code> processed through some function</li>
  <li>User emails me <code>challenge code</code></li>
  <li>Encrypt <code>challenge code</code> with a <code>private key</code> </li>
  <li>The encrypted result is considered the <code>license key</code> which I send to user</li>
  <li>User saves <code>license key</code> into the application</li>
  </ul>
  
  <p>Validation Process: </p>
  
  <ul>
  <li>On app load, retrieve <code>license key</code></li>
  <li>Decrypt <code>license key</code> using a <code>public key</code> stored in app</li>
  <li>The result is the <code>challenge code</code> the user had sent before</li>
  <li>Take that <code>challenge code</code> revert it back to a <code>site collection id</code></li>
  <li>Retrieve the <code>site collection id</code> app is currently running on</li>
  <li>Compare the two to determine if <code>license key</code> is valid</li>
  </ul>
  
  <p>Does this make sense? The one thing I'm not sure about is the public/private key stuff and if there's a way to do this in JavaScript. </p>
  
  <hr>
  
  <p>I know it's impossible to 100% secure client-side applications. I'm just looking for something to prevent someone from <strong>easily</strong> distributing the application</p>