diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2019-08-04 16:41:01 +0200 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2019-08-04 17:05:58 +0200 |
commit | b6cebd53fcafd3088fc8361f6d3466166f75410b (patch) | |
tree | a1a3912fb9e91e249e433df0a9b79572f46340f3 /rsa/core.py | |
parent | 6760eb76e665dc81863a82110164c4b3b38e7ee9 (diff) | |
download | rsa-git-b6cebd53fcafd3088fc8361f6d3466166f75410b.tar.gz |
Added type annotations + some fixes to get them correct
One functional change: `CryptoOperation.read_infile()` now reads bytes
from `sys.stdin` instead of text. This is necessary to be consistent with
the rest of the code, which all deals with bytes.
Diffstat (limited to 'rsa/core.py')
-rw-r--r-- | rsa/core.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/rsa/core.py b/rsa/core.py index 0660881..42f7bac 100644 --- a/rsa/core.py +++ b/rsa/core.py @@ -21,14 +21,14 @@ mathematically on integers. """ -def assert_int(var, name): +def assert_int(var: int, name: str): if isinstance(var, int): return raise TypeError('%s should be an integer, not %s' % (name, var.__class__)) -def encrypt_int(message, ekey, n): +def encrypt_int(message: int, ekey: int, n: int) -> int: """Encrypts a message using encryption key 'ekey', working modulo n""" assert_int(message, 'message') @@ -44,7 +44,7 @@ def encrypt_int(message, ekey, n): return pow(message, ekey, n) -def decrypt_int(cyphertext, dkey, n): +def decrypt_int(cyphertext: int, dkey: int, n: int) -> int: """Decrypts a cypher text using the decryption key 'dkey', working modulo n""" assert_int(cyphertext, 'cyphertext') |