OXIESEC PANEL
- Current Dir:
/
/
opt
/
alt
/
python311
/
lib
/
python3.11
/
site-packages
/
validators
Server IP: 2a02:4780:11:1594:0:ef5:22d7:a
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
01/09/2025 02:18:04 AM
rwxr-xr-x
📄
__init__.py
1.86 KB
05/14/2024 03:18:23 PM
rw-r--r--
📁
__pycache__
-
05/14/2024 03:18:23 PM
rwxr-xr-x
📄
_extremes.py
1.01 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
_tld.txt
9.4 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
between.py
2.39 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
btc_address.py
1.62 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
card.py
5.63 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
country.py
14.57 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
cron.py
2.23 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
domain.py
2.4 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
email.py
2.72 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
encoding.py
1.34 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
finance.py
3.22 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
hashes.py
3.21 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
hostname.py
4.05 KB
05/14/2024 03:18:23 PM
rw-r--r--
📁
i18n
-
05/14/2024 03:18:23 PM
rwxr-xr-x
📄
iban.py
1.05 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
ip_address.py
4.34 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
length.py
1.45 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
mac_address.py
865 bytes
05/14/2024 03:18:23 PM
rw-r--r--
📄
py.typed
0 bytes
05/14/2024 03:18:23 PM
rw-r--r--
📄
slug.py
750 bytes
05/14/2024 03:18:23 PM
rw-r--r--
📄
uri.py
1.78 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
url.py
7.23 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
utils.py
3.1 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
uuid.py
1.04 KB
05/14/2024 03:18:23 PM
rw-r--r--
Editing: hashes.py
Close
"""Hashes.""" # standard import re # local from .utils import validator @validator def md5(value: str, /): """Return whether or not given value is a valid MD5 hash. Examples: >>> md5('d41d8cd98f00b204e9800998ecf8427e') # Output: True >>> md5('900zz11') # Output: ValidationError(func=md5, args={'value': '900zz11'}) Args: value: MD5 string to validate. Returns: (Literal[True]): If `value` is a valid MD5 hash. (ValidationError): If `value` is an invalid MD5 hash. """ return re.match(r"^[0-9a-f]{32}$", value, re.IGNORECASE) if value else False @validator def sha1(value: str, /): """Return whether or not given value is a valid SHA1 hash. Examples: >>> sha1('da39a3ee5e6b4b0d3255bfef95601890afd80709') # Output: True >>> sha1('900zz11') # Output: ValidationError(func=sha1, args={'value': '900zz11'}) Args: value: SHA1 string to validate. Returns: (Literal[True]): If `value` is a valid SHA1 hash. (ValidationError): If `value` is an invalid SHA1 hash. """ return re.match(r"^[0-9a-f]{40}$", value, re.IGNORECASE) if value else False @validator def sha224(value: str, /): """Return whether or not given value is a valid SHA224 hash. Examples: >>> sha224('d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f') # Output: True >>> sha224('900zz11') # Output: ValidationError(func=sha224, args={'value': '900zz11'}) Args: value: SHA224 string to validate. Returns: (Literal[True]): If `value` is a valid SHA224 hash. (ValidationError): If `value` is an invalid SHA224 hash. """ return re.match(r"^[0-9a-f]{56}$", value, re.IGNORECASE) if value else False @validator def sha256(value: str, /): """Return whether or not given value is a valid SHA256 hash. Examples: >>> sha256( ... 'e3b0c44298fc1c149afbf4c8996fb924' ... '27ae41e4649b934ca495991b7852b855' ... ) # Output: True >>> sha256('900zz11') # Output: ValidationError(func=sha256, args={'value': '900zz11'}) Args: value: SHA256 string to validate. Returns: (Literal[True]): If `value` is a valid SHA256 hash. (ValidationError): If `value` is an invalid SHA256 hash. """ return re.match(r"^[0-9a-f]{64}$", value, re.IGNORECASE) if value else False @validator def sha512(value: str, /): """Return whether or not given value is a valid SHA512 hash. Examples: >>> sha512( ... 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce' ... '9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af9' ... '27da3e' ... ) # Output: True >>> sha512('900zz11') # Output: ValidationError(func=sha512, args={'value': '900zz11'}) Args: value: SHA512 string to validate. Returns: (Literal[True]): If `value` is a valid SHA512 hash. (ValidationError): If `value` is an invalid SHA512 hash. """ return re.match(r"^[0-9a-f]{128}$", value, re.IGNORECASE) if value else False