summaryrefslogtreecommitdiff
path: root/rsa/_compat.py
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2019-08-04 16:41:01 +0200
committerSybren A. Stüvel <sybren@stuvel.eu>2019-08-04 17:05:58 +0200
commitb6cebd53fcafd3088fc8361f6d3466166f75410b (patch)
treea1a3912fb9e91e249e433df0a9b79572f46340f3 /rsa/_compat.py
parent6760eb76e665dc81863a82110164c4b3b38e7ee9 (diff)
downloadrsa-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/_compat.py')
-rw-r--r--rsa/_compat.py7
1 files changed, 2 insertions, 5 deletions
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.