SourceCode_7.py 847 B

12345678910111213141516171819202122
  1. def Encrypt(self, textToEncrypt):
  2. location = 0
  3. encryptedText = []
  4. offsetIndex = 0
  5. while location < len(textToEncrypt):
  6. if offsetIndex < 9: # Let's make sure we keep it in-bounds.
  7. offsetIndex += 1
  8. elif offsetIndex == 9:
  9. offsetIndex = 0
  10. charValue = ord(textToEncrypt[location])
  11. offsetValue = encryptionList[offsetIndex]
  12. finalValue = int(charValue) + int(offsetValue)
  13. encryptedText.append(str(finalValue))
  14. location += 1
  15. location = 0
  16. finalString = ""
  17. while location < len(encryptedText):
  18. finalString += str(encryptedText[location])
  19. if location != len(encryptedText):
  20. finalString += " "
  21. location += 1
  22. return finalString