diff options
Diffstat (limited to 'rsa/pem.py')
-rw-r--r-- | rsa/pem.py | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -17,9 +17,13 @@ """Functions that load and write PEM-encoded files.""" import base64 +import typing +# Should either be ASCII strings or bytes. +FlexiText = typing.Union[str, bytes] -def _markers(pem_marker): + +def _markers(pem_marker: FlexiText) -> typing.Tuple[bytes, bytes]: """ Returns the start and end PEM markers, as bytes. """ @@ -31,7 +35,7 @@ def _markers(pem_marker): b'-----END ' + pem_marker + b'-----') -def load_pem(contents, pem_marker): +def load_pem(contents: FlexiText, pem_marker: FlexiText) -> bytes: """Loads a PEM file. :param contents: the contents of the file to interpret @@ -97,7 +101,7 @@ def load_pem(contents, pem_marker): return base64.standard_b64decode(pem) -def save_pem(contents, pem_marker): +def save_pem(contents: bytes, pem_marker: FlexiText) -> bytes: """Saves a PEM file. :param contents: the contents to encode in PEM format |