Skip to content

Commit

Permalink
doc: hash_create gets a docstring
Browse files Browse the repository at this point in the history
`hash_create` does something non-trivial so let's write down what it
does.

Signed-off-by: Simon de Vlieger <[email protected]>
  • Loading branch information
supakeen committed Jun 25, 2024
1 parent e0b5f2c commit 21c722a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/pinnwand/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def guess_language(raw: str, filename: Optional[str] = None) -> str:


def hash_create(length: int = 16) -> str:
"""Create a random string by taking `length` random bytes and encoding them
as base32. This makes them URL-safe and uses discernable characters to
reduce typos."""

return b32encode(urandom(length)).decode("ascii").replace("=", "")


Expand Down

0 comments on commit 21c722a

Please sign in to comment.