Chapter 24 – Public Key Cryptography and the RSA Cipher 407
the start of the first block will be 0 , the index of the start of the second block will be 128 , the
index of the start of the third block will be 256 , and so on as long as the index is less than
len(messageBytes).
The min() and max() Functions
The min() function returns the smallest (that is, the minimum) value of its arguments. Try
typing the following into the interactive shell:
min(13, 32, 13, 15, 17, 39)
13
min(21, 45, 18, 10)
10
You can also pass min() a single argument if the argument is a list or tuple value. In this case,
min() returns the smallest value in that list or tuple. Try typing the following into the interactive
shell:
min([31, 26, 20, 13, 12, 36])
12
spam = (10, 37, 37, 43, 3)
min(spam)
3
The max() function will return the largest (that is, the maximum) value of its arguments:
max(18, 15, 22, 30, 31, 34)
34
rsaCipher.py
Calculate the block integer for this block of text
- blockInt = 0
- for i in range(blockStart, min(blockStart + blockSize,
len(messageBytes))):
The code inside line 43’s for loop will create the very large integer for a single block. Recall
from earlier in this chapter that this is done by multiplying the ASCII value of the character by
(256 ^ index-of-character).