Skip to content

Commit

Permalink
feat: add SHA256 encryption method to inline stream maps
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-schulz-mh authored Dec 27, 2024
1 parent 920d630 commit 4c4f922
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions singer_sdk/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def md5(string: str) -> str:
return hashlib.md5(string.encode("utf-8")).hexdigest() # noqa: S324


def sha256(value: str) -> str:
"""Digest a string using SHA256. This is a function for inline calculations."""

return hashlib.sha256(value.encode("utf-8")).hexdigest()


StreamMapsDict: TypeAlias = dict[str, t.Union[str, dict, None]]


Expand Down Expand Up @@ -307,6 +313,7 @@ def functions(self) -> dict[str, t.Callable]:
"""
funcs: dict[str, t.Any] = simpleeval.DEFAULT_FUNCTIONS.copy()
funcs["md5"] = md5
funcs["sha256"] = sha256
funcs["datetime"] = datetime
funcs["bool"] = bool
funcs["json"] = json
Expand Down

0 comments on commit 4c4f922

Please sign in to comment.