fix merge conflict

This commit is contained in:
mungai-njoroge
2024-03-27 08:39:30 +03:00
19 changed files with 161 additions and 12 deletions
+8 -2
View File
@@ -32,5 +32,11 @@ def create_hash(*args: str, decode=False, limit=10) -> str:
str_ = unidecode(str_)
str_ = str_.encode("utf-8")
str_ = hashlib.sha256(str_).hexdigest()
return str_[-limit:]
str_ = hashlib.sha1(str_).hexdigest()
# REVIEW Switched to sha1 hashlib.sha256(str_).hexdigest()
# REVIEW Take the first limit/2 and last limit/2 characters
# This is to avoid collisions
return str_[:limit // 2] + str_[-limit // 2:] if limit % 2 == 0 else str_[:limit // 2] + str_[-limit // 2 - 1:]
# return str_[-limit:]
+2
View File
@@ -3,10 +3,12 @@ import socket as Socket
def has_connection(host="google.it", port=80, timeout=3):
"""
# REVIEW Was:
Host: 8.8.8.8 (google-public-dns-a.google.com)
OpenPort: 53/tcp
Service: domain (DNS/TCP)
"""
try:
Socket.setdefaulttimeout(timeout)
Socket.socket(Socket.AF_INET, Socket.SOCK_STREAM).connect((host, port))