title: Algorithms for encrypting a PIN code (4 purely random digits) into same-sized cipher text
body: <p>We have PIN codes that need encryption, that are purely random and aren't selectable by user.</p>
  
  <p>They have to be sent in third-world countries over connections where bandwidth is a real issue. So we don't want to send 256 bytes of encrypted data. Most encryption algorithms are designed for natural language which has lots of patterns so the algorithm tries to obscure these patterns. We need something simpler but still standard.</p>
  
  <p>E.g.</p>
  
  <p>PIN: 1234</p>
  
  <p>key: 'secret key of whatever length'</p>
  
  <p>Example cipher text: 7301</p>
  
  <p>XOR is a problem as anyone with two PIN codes and corresponding cipher text can guess the key.</p>
  
  <p>What algorithm can we use? A Python implementation is what we are looking for.</p>
  
  <h2>Edits:</h2>
  
  <p>Sorry for my lack of clarity;</p>
  
  <ul>
  <li>We're looking for symmetric encryption. Goal is to protect PINs from being easily discoverable by our own staff. </li>
  <li>Bandwidth is an issue. A realistic case: we might need to send data for say 500,000 cards over GPRS. If, say, the padded cipher text adds 256 bytes per card that would take an extra 5 hours to download. Hence we are looking for short cipher text.</li>
  <li>"Most encryption algorithms are designed for natural language" -> yes, this isn't true but, what I was trying to mean was that most popular encryption algorithms will assume the plaintext is not random, which doesn't match our case. Also, all the ones I looked at produced block output where each block is a particular number of bytes, so the length of a short plaintext isn't obvious. We don't need that, everyone knows most PINs are 4 digits.</li>
  <li>"Python implementation" -> just meant we want to be able to use it in python, i.e. an package exists for it. </li>
  </ul>