ipungg-junior / yummypiv

The Restaurant Management Web App is a software solution designed to help restaurant owners and managers efficiently manage daily operations. This application aims to enhance productivity, facilitate monitoring, and improve customer experience.
https://yummypiv.com
0 stars 0 forks source link

Potentially duplicate hash of visit_id #42

Closed ipungg-junior closed 3 weeks ago

ipungg-junior commented 3 weeks ago

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 :

please add some salt to make it unique (timestamp)

ipungg-junior commented 3 weeks ago

New rev function

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
ipungg-junior commented 3 weeks ago

Solved

Generate function has been updated by (https://github.com/ipungg-junior/yummypiv/commit/92fd530f6b72cafb700d8d4029a1f32971f45b53)