0

I'm making a program that encrypts a piece of text given, or does it off of a file. The encryption method i'm trying to use involves reading the key, converting it from text to an ASCII value. It then appends it into a variable called Offsets.

for i in range(KeyLength):
  Offsets.append(ord(Key[i]))
EncryptionLength = len(EncryptionText)

What i'm trying to do is to divide the EncryptionText by the KeyLength. If it returns a decimal, i want it to round up. I've tried using // but i'm kind of stumped.

MCrafterX
  • 5
  • 1

1 Answers1

0

Try using math.ceil:

>>> import math
>>> EncryptionText = 'abcdefghijkl' # 12 characters
>>> EncryptionLength = 5
>>> len(EncryptionText)/EncryptionLength)
2.4
>>> math.ceil(len(EncryptionText)/EncryptionLength))
3
Sash Sinha
  • 18,743
  • 3
  • 23
  • 40