Closed ipungg-junior closed 3 weeks ago
Add timestamp salt to hash function
def generate_visit_id(ip_addr, path, user_agent):
# Get the current timestamp to use as a salt
timestamp = str(time.time())
# Concatenate the input values with the timestamp to form a unique string
visit_string = f"{ip_addr}_{path}_{user_agent}_{timestamp}"
# Use SHA-256 to generate a unique hash for the visit
visit_id = hashlib.sha256(visit_string.encode()).hexdigest()
return visit_id
Generate function has been updated by (https://github.com/ipungg-junior/yummypiv/commit/92fd530f6b72cafb700d8d4029a1f32971f45b53)
Duplicate of visit_id
When generate id function called, it throw 3 param, ip, path and useragent . if same user had use same IP Address while 6 hour or more , this will be duplicate hash, cause the request has same ip/path/useragent like before
Code :