Data to be Signed: Suppose you have a message or data that you want to sign to prove its authenticity and integrity.
Hashing: First, this message is subjected to a cryptographic hash function (commonly SHA-1, SHA-256, or similar). The purpose of this step is to produce a fixed-length hash value, which represents the unique fingerprint of the data. The hash value is considerably shorter than the original data.
Signing: The DSA algorithm then uses this hash value to create a digital signature. The signature is generated using the private key of the signer and some mathematical operations.
Verification: The recipient of the data, who has access to the corresponding public key, can use the same cryptographic hash function to generate a hash value from the received data. They then use the sender's public key to verify the digital signature.
2. Why hash Tables ?
Example :
There is an array, and we’ve got a bunch of names stored in it. Let’s say you want to search
for the key “Randy”.
Very inefficient !!!
3. Hash table offers a remarkable solution.
With the help of a hash function, the name "Randy" can be instantly
transformed into an index, revealing precisely where Randy is stored
in the array.
4. Hash Functions
• For hashing tables, a hash function converts input data into a fixed-size index
to efficiently store or retrieve information.
• Usually Hash functions are very complex in nature.
• But for this case we can use a simple one.
Sum = ASCII(R) + ASCII(A) + ASCII(N) + ASCII(D) + ASCII(Y) = 82 + 65 + 78 + 68 + 89
= 382
Hash Code = Sum % 100
H(Randy) = Sum(ASCII(RANDY))
6. Collisions
Collision in hashing happens when 2 or more values are assigned the same index by the
hashing function.
Example :
To store the two names RANDY and ERIC in an array of size 7. If we get the same hash code
.
8. Open Addressing
If a spot is already taken, we just store the colliding element in the next index. When we later
on try to search the colliding element, we first go to it’s original position where the hash
functions tells us to go, and if it’s not there, then we look at the next index.
9. Separate Chaining
• It is basically storing multiple names in one array by using linked
lists.
• Instead of storing the names in the indices of the array, each index will
hold a pointer that points to the head of a linked list that has a list of
names.
11. Time Complexity
• The time complexity of hash tables for inserting, deleting and
searching is expected to be constant, in an average case.
• The worst case time complexity is O(n).
Worst Case :