This repository was archived by the owner on Apr 19, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -306,11 +306,13 @@ def encode(self, encoding=None):
306
306
>>> mh.encode()
307
307
b'\x01\x04TEST'
308
308
309
- If an `encoding` is specified, it is used to encode the binary digest
310
- before returning it (see `Codecs` for supported codecs):
309
+ If the name of an `encoding` is specified, it is used to encode the
310
+ binary digest before returning it (see `Codecs` for supported codecs):
311
311
312
312
>>> mh.encode('base64')
313
313
b'AQRURVNU'
314
+
315
+ If the `encoding` is not available, a `KeyError` is raised.
314
316
"""
315
317
try :
316
318
fc = self .func .value
@@ -374,7 +376,7 @@ def decode(mhash, encoding=None):
374
376
>>> mh == (Func.sha1, mhash[2:])
375
377
True
376
378
377
- If an `encoding` is specified, it is used to decode the digest
379
+ If the name of an `encoding` is specified, it is used to decode the digest
378
380
before parsing it (see `Codecs` for supported codecs):
379
381
380
382
>>> import base64
@@ -383,8 +385,8 @@ def decode(mhash, encoding=None):
383
385
>>> emh == mh
384
386
True
385
387
386
- If the digest has an invalid format or contains invalid data, a
387
- `ValueError` is raised.
388
+ If the `encoding` is not available, a `KeyError` is raised. If the digest
389
+ has an invalid format or contains invalid data, a `ValueError` is raised.
388
390
"""
389
391
mhash = bytes (mhash )
390
392
if encoding :
You can’t perform that action at this time.
0 commit comments