Explore demos on Password Security and ETA Computation.
NVIDIA Data Science Prep
Resources and tools for NVIDIA data science preparation.
Interactive System Design Hub
Explore complex system concepts through interactive visualizations.
Password Security
Understand how password hashing, salting, and rainbow tables work.
ETA Computation
Learn about map graphs, shortest paths, traffic, and map matching.
Interactive Password Security Explained
Follow the steps to understand how password hashing and salting work.
Step 1 & 2: Hashing & Storing Fingerprints
Enter a password to see how it's transformed into a "fingerprint" (hash) for storage.
Your Password:
Generated Fingerprint (Hash):
The server transforms the password using a hash function to create the fingerprint.
The database stores only the fingerprint and not the original password.
Simulated Database:
Username
Password Fingerprint
user123
---
Step 3: The One-Way Hash Function
Hash functions are designed to be one-way. This means it's computationally infeasible to reverse the process and get the original password from its fingerprint.
Generated Fingerprint:
Original Password:
Cannot be retrieved!
The one-way hash function prevents retrieval of the password from a fingerprint. This is a key security feature.
Step 4 & 5: Login & Verification
When you try to log in, the system re-hashes the password you enter and compares it to the stored fingerprint.
Try logging in with the password you set in Step 1 (or a different one to see it fail).
Password Entered for Login:
Newly Generated Fingerprint:
Stored Fingerprint in Database:
The system regenerates the fingerprint whenever the user enters a password during a login attempt.
The system compares this regenerated fingerprint against the stored value to grant or deny access.
Step 6 & 7: The Rainbow Table Threat
If an attacker gets access to your database of fingerprints, they can use a "rainbow table" – a pre-computed list of passwords and their corresponding hashes – to find the original passwords.
Simplified Rainbow Table:
Password
Fingerprint (Hash)
password123
qwerty
admin
your_password_here
secret
It's possible to find a password from a fingerprint if the hash is in a rainbow table.
A rainbow table is a map between pre-computed fingerprints and passwords.
This is a major vulnerability if only plain hashes are stored!
Step 8, 9 & 10: Salting to the Rescue!
To combat rainbow tables, we use "salt" – a unique random string added to each password before hashing.
Password:
Generated Salt (unique per user):
Password + Salt:
New Fingerprint (Hash of Password + Salt):
The system adds salt, a unique random string, to the password to invalidate rainbow table values.
The database stores the salt alongside the (salted) fingerprint.
Simulated Database (with Salt):
Username
Salt
Password Fingerprint (Salted)
user123
---
---
Now, if an attacker tries the rainbow table against the salted hash...
The rainbow table (which contains hashes of unsalted passwords) will not find a match for the salted hash!
During login, the server retrieves the user's salt, combines it with the entered password, hashes the result, and then compares it to the stored salted fingerprint.
Salting significantly improves password security by making rainbow table attacks impractical!
Interactive ETA Computation Explained
Discover how mapping services calculate your Estimated Time of Arrival.
1. Physical Map as a Graph
Mapping services represent the real world (roads, intersections) as a mathematical graph.
Nodes (Vertices): Represent locations like intersections, points of interest, or segments of a road.
Edges: Represent roads or paths connecting these locations.
This graph abstraction allows complex road networks to be analyzed computationally. Edges are often directed (e.g., one-way streets) and weighted (e.g., by distance or travel time).
2. ETA by Shortest Path
The Estimated Time of Arrival (ETA) is typically calculated by finding the "shortest path" between your start and end points in this graph.
"Shortest" usually means the path with the minimum total travel time. Edge weights represent the time to traverse a road segment.
Algorithms like Dijkstra's or A* are commonly used to find these shortest paths. The sum of weights along the chosen path gives the ETA.
3. Scalability Challenges
Real-world road networks are massive, with millions of nodes and edges. Running standard shortest path algorithms (like Dijkstra's) directly on the entire graph for every request can be too slow.
Dijkstra's algorithm has a time complexity of roughly O(E log V) or O(V log V + E) with a priority queue, where V is vertices (nodes) and E is edges. For a continental-scale map, this is computationally expensive for real-time queries.
While effective for smaller graphs, the sheer scale of global road networks necessitates more advanced techniques to provide fast ETAs for millions of users simultaneously.
4. Graph Partitioning & Precomputation
To manage complexity, the graph is often partitioned into smaller regions or cells. Paths within these partitions, or between important "transit" nodes connecting partitions, can be precomputed.
Precomputation involves calculating and storing shortest paths for many pairs of nodes, especially within partitions or between boundary nodes of partitions. This shifts some computational load from query time to an offline process.
Techniques like Contraction Hierarchies or Hub Labeling build upon these ideas, creating shortcuts or overlay graphs to speed up queries significantly.
5. Time Complexity Reduction
By partitioning and precomputing, the search space for a given query is dramatically reduced. Instead of searching the entire global graph, the algorithm might only need to consider paths through a few relevant partitions and precomputed shortcuts.
While the user's statement "O(n^2) to O(n)" is a simplification, the goal of partitioning and precomputation techniques (like Contraction Hierarchies, Transit Node Routing, Hub Labeling) is to achieve query times that are significantly faster than running Dijkstra on the full graph, often sub-linear or near-constant for many queries after extensive preprocessing.
The preprocessing step can be very time-consuming (e.g., hours or days), but it's done offline. The payoff is extremely fast query times (e.g., milliseconds) when a user requests an ETA.
6. Incorporating Traffic Information
Accurate ETAs depend on real-time traffic conditions. This means the weights of edges in the graph must be dynamic.
Traffic data is collected from various sources (e.g., GPS probes from users' phones, road sensors). This data is used to update the travel time (weights) for affected road segments (edges). Shortest path calculations then use these updated weights, potentially rerouting through less congested areas.
Handling dynamic edge weights with highly optimized precomputed structures can be challenging, often requiring hybrid approaches or periodic updates to the precomputed data.
7. The Need for Map Matching
GPS data from devices isn't perfectly accurate. Raw GPS coordinates might place a vehicle slightly off-road, in a parallel street, or show erratic movements due to signal noise or urban canyons.
Map Matching is the process of aligning a sequence of observed user positions (GPS points) to the road network on the digital map.
Accurate map matching is crucial for:
Determining which road segment a user is actually on.
Providing correct turn-by-turn directions.
Collecting reliable traffic data (attributing speed to the correct road).
Improving ETA accuracy by understanding the true path taken.
8. Algorithms for Map Matching
Several algorithms are used for map matching, often considering geometric proximity, topological connectivity of roads, and the history of movements.
Kalman Filter: A statistical technique that can estimate the true position of a vehicle by considering previous estimates and new (noisy) GPS measurements. It's good for real-time tracking and smoothing trajectories.
Viterbi Algorithm: Often used with Hidden Markov Models (HMMs). The road segments are "hidden states," and GPS points are "observations." The Viterbi algorithm finds the most likely sequence of road segments (path) given the sequence of GPS points.
Fuzzy Logic and Geometric Heuristics: Simpler methods might use rules based on distance to road segments, heading direction, and road connectivity.
The choice of algorithm depends on the desired accuracy, computational resources, and whether it's for real-time or post-processing applications. These algorithms help ensure that the system understands the user's actual path on the road network, leading to better ETAs and navigation.