title: Python ASCII encryption program
body: <p>Good day,</p>
  
  <p>I have created a simple ASCII encryption program and I just have 3 questions about it:</p>
  
  <ol>
  <li>How could I check if the key in entered incorrectly and tell my program not to attempt to decrypt if it has been entered incorrectly.</li>
  <li>Why is the encrypted text longer than the original?</li>
  <li>If I wanted to encrypt other things not ASCII text how hard would it be?</li>
  </ol>
  
  <p>Thank you here is my code and results below:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import time
  key = "This■isôthe╝key¦b££glkHPAfgbm(*&amp;%$$*(■ô▀"
  string = "Encryption the hell out of me, even if I repeatttttttt lettersssss you can't tell"
  
  entext = ""
  detext = ""
  keycnt=0
  
  print("Displaing Text to be Encrypted")
  time.sleep(1)
  print(string)
  time.sleep(5)
  
  #Loops through the string and the key and adds the ascii values together to create a Encrypted character
  for sLetter in string:
      entext += chr(ord(sLetter) + ord(key[keycnt]))
      keycnt += 1
      if keycnt == len(key):
          keycnt =0
  
  
  print("Displaying encrypted Text")
  time.sleep(1)
  print(entext)
  
  #Resetting key position
  keycnt=0
  
  #Loops through the string and the key and subtracts the ascii values together to create a decrypted character
  for sLetter in entext:
      detext += chr(ord(sLetter) - ord(key[keycnt]))
      keycnt += 1
      if keycnt == len(key):
          keycnt =0
  time.sleep(2)
  
  print("Displaying decrypted Text")
  time.sleep(1)
  print(detext)
  time.sleep(1)</code></pre>
  </div>
  </div>
  </p>