(request, algorithm='md5', digest='hex')
| 1376 | |
| 1377 | @staticmethod |
| 1378 | def hash(request, algorithm='md5', digest='hex'): |
| 1379 | if algorithm == 'keccak': |
| 1380 | binary = bytes(keccak.SHA3(request)) |
| 1381 | else: |
| 1382 | h = hashlib.new(algorithm, request) |
| 1383 | binary = h.digest() |
| 1384 | if digest == 'base64': |
| 1385 | return Exchange.binary_to_base64(binary) |
| 1386 | elif digest == 'hex': |
| 1387 | return Exchange.binary_to_base16(binary) |
| 1388 | return binary |
| 1389 | |
| 1390 | @staticmethod |
| 1391 | def hmac(request, secret, algorithm=hashlib.sha256, digest='hex'): |
no test coverage detected