formalised project structure

This commit is contained in:
Emile Clark-Boman 2025-06-21 19:05:47 +10:00
parent 897272d7c1
commit 6f8a7322f2
14 changed files with 177 additions and 71 deletions

17
bcrypt/lib/format.py Normal file
View file

@ -0,0 +1,17 @@
from typing import Any
from bcrypt.lib.math import clamp_min
'''
Apply left padding to str(x) for parameter x: Any
'''
def lpad(x: Any, n: int, pad: chr = ' ') -> str:
x = str(x)
width = clamp_min(n - len(x), 0)
return width * pad + x
'''
Left pad an integer's binary representation with zeros
'''
def lpadbin(x: int, n: int) -> str:
return lpad(bin(x)[2:], n, pad='0')