File: crypto.py

package info (click to toggle)
python-eth-utils 5.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,140 kB
  • sloc: python: 5,985; makefile: 238
file content (20 lines) | stat: -rw-r--r-- 362 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from typing import (
    Optional,
    Union,
)

from eth_hash.auto import (
    keccak as keccak_256,
)

from .conversions import (
    to_bytes,
)


def keccak(
    primitive: Optional[Union[bytes, int, bool]] = None,
    hexstr: Optional[str] = None,
    text: Optional[str] = None,
) -> bytes:
    return bytes(keccak_256(to_bytes(primitive, hexstr, text)))