From b6cebd53fcafd3088fc8361f6d3466166f75410b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Sun, 4 Aug 2019 16:41:01 +0200 Subject: 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. --- rsa/_compat.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'rsa/_compat.py') diff --git a/rsa/_compat.py b/rsa/_compat.py index 843583c..b31331e 100644 --- a/rsa/_compat.py +++ b/rsa/_compat.py @@ -21,14 +21,11 @@ import sys from struct import pack -def byte(num):## XXX +def byte(num: int): """ Converts a number between 0 and 255 (both inclusive) to a base-256 (byte) representation. - Use it as a replacement for ``chr`` where you are expecting a byte - because this will work on all current versions of Python:: - :param num: An unsigned integer between 0 and 255 (both inclusive). :returns: @@ -37,7 +34,7 @@ def byte(num):## XXX return pack("B", num) -def xor_bytes(b1, b2): +def xor_bytes(b1: bytes, b2: bytes) -> bytes: """ Returns the bitwise XOR result between two bytes objects, b1 ^ b2. -- cgit v1.2.1