title: basics of python encryption w/ hashlib sha1
body: <p>I'm struggling to fully understand how encryption works and is coded, particularly with python. I'm just trying to get the basics down and create code in the simplest form.</p>
  
  <p>I'm going to be passing a userID between two different sites, but obviously I need this to be encrypted with a private key so Website2 knows it came from Website1. This seems to be the code for me:
  <a href="http://docs.python.org/library/hashlib.html#module-hashlib" rel="noreferrer">http://docs.python.org/library/hashlib.html#module-hashlib</a>, but it doesn't have very good examples (or maybe I'm in the wrong spot).</p>
  
  <p>The problem I'm having is fully understanding how to encode and decode.</p>
  
  <p>So lets say the shared private key which each website will know is:</p>
  
  <pre><code>shared_private_key = "ABCDEF"
  </code></pre>
  
  <p>And I want Website1 to pass to Website2 the userID of:</p>
  
  <pre><code>userID = "123456"
  </code></pre>
  
  <p>How would Website1 encrypt my userID with the private key in a fashion that the encryption can be sent via HTTP headers, and then have Website2 decrypt and be able to read the userID using the shared private key?</p>
  
  <p>I apologize for asking such a basic question, but I'm failing to grasp how this should be done. Thanks.</p>