diff options
author | José Padilla <jpadilla@webapplicate.com> | 2015-01-18 13:32:40 -0400 |
---|---|---|
committer | José Padilla <jpadilla@webapplicate.com> | 2015-01-18 13:32:40 -0400 |
commit | 6cd17161d28520257de4d8eaf8e742d0a683bd1f (patch) | |
tree | e9cdd162d6323d50ffe855e9cb4e960e292ae161 | |
parent | 6290a1c8b5928d691f9fc91b733550b93b5f8cc7 (diff) | |
download | pyjwt-6cd17161d28520257de4d8eaf8e742d0a683bd1f.tar.gz |
Tweak comment blocks
-rw-r--r-- | jwt/__init__.py | 4 | ||||
-rw-r--r-- | jwt/algorithms.py | 33 |
2 files changed, 22 insertions, 15 deletions
diff --git a/jwt/__init__.py b/jwt/__init__.py index b9a9986..c3a9e9c 100644 --- a/jwt/__init__.py +++ b/jwt/__init__.py @@ -40,7 +40,9 @@ _algorithms = {} def register_algorithm(alg_id, alg_obj): - """ Registers a new Algorithm for use when creating and verifying JWTs """ + """ + Registers a new Algorithm for use when creating and verifying tokens. + """ if alg_id in _algorithms: raise ValueError('Algorithm already has a handler.') diff --git a/jwt/algorithms.py b/jwt/algorithms.py index 89ea75b..dec6577 100644 --- a/jwt/algorithms.py +++ b/jwt/algorithms.py @@ -19,7 +19,9 @@ except ImportError: def _register_default_algorithms(): - """ Registers the algorithms that are implemented by the library """ + """ + Registers the algorithms that are implemented by the library. + """ register_algorithm('none', NoneAlgorithm()) register_algorithm('HS256', HMACAlgorithm(hashlib.sha256)) register_algorithm('HS384', HMACAlgorithm(hashlib.sha384)) @@ -36,32 +38,35 @@ def _register_default_algorithms(): class Algorithm(object): - """ The interface for an algorithm used to sign and verify JWTs """ + """ + The interface for an algorithm used to sign and verify tokens. + """ def prepare_key(self, key): """ Performs necessary validation and conversions on the key and returns - the key value in the proper format for sign() and verify() + the key value in the proper format for sign() and verify(). """ raise NotImplementedError def sign(self, msg, key): """ - Returns a digital signature for the specified message using the - specified key value + Returns a digital signature for the specified message + using the specified key value. """ raise NotImplementedError def verify(self, msg, key, sig): """ - Verifies that the specified digital signature is valid for the specified - message and key values. + Verifies that the specified digital signature is valid + for the specified message and key values. """ raise NotImplementedError class NoneAlgorithm(Algorithm): """ - Placeholder for use when no signing or verification operations are required + Placeholder for use when no signing or verification + operations are required. """ def prepare_key(self, key): return None @@ -75,8 +80,8 @@ class NoneAlgorithm(Algorithm): class HMACAlgorithm(Algorithm): """ - Performs signing and verification operations using HMAC and the specified - hash function + Performs signing and verification operations using HMAC + and the specified hash function. """ def __init__(self, hash_alg): self.hash_alg = hash_alg @@ -100,8 +105,8 @@ if has_crypto: class RSAAlgorithm(Algorithm): """ - Performs signing and verification operations using RSASSA-PKCS-v1_5 and - the specified hash function + Performs signing and verification operations using + RSASSA-PKCS-v1_5 and the specified hash function. """ def __init__(self, hash_alg): @@ -154,8 +159,8 @@ if has_crypto: class ECAlgorithm(Algorithm): """ - Performs signing and verification operations using ECDSA and the - specified hash function + Performs signing and verification operations using + ECDSA and the specified hash function """ def __init__(self, hash_alg): self.hash_alg = hash_alg |