This commit is contained in:
2025-07-14 11:09:16 -03:00
parent cea6b61f51
commit 51cc1bbbb5
11 changed files with 242 additions and 57 deletions

View File

@@ -1,4 +1,6 @@
import hashlib
import random
import string
def first_word(s: str) -> str:
@@ -13,6 +15,11 @@ def truncate_str(s: str, maxlen: int = 30) -> str:
return s[: maxlen - 3] + '...'
def random_str(maxlen: int = 10) -> str:
"""Returns a random string of letters."""
return ''.join(random.choice(string.ascii_letters) for _ in range(maxlen))
def md5_hash(s: str) -> str:
"""Computes the MD5 hash of a string."""
return hashlib.md5(s.encode()).hexdigest()