CSS EXP 5 Final
CSS EXP 5 Final
Hashing algorithm involves rounds of above hash function like a block cipher. Each round takes an input of a
fixed size, typically a combination of the most recent message block and the output of the last round.
This process is repeated for as many rounds as are required to hash the entire message. Schematic of hashing
algorithm is depicted in the following illustration −
Since, the hash value of first message block becomes an input to the second hash operation, output of which
alters the result of the third operation, and so on. This effect, known as an avalanche effect of hashing.
Algorithm:
1. Initialize a variable sum to 0.
2. Iterate through each character in the input string.
3. For each character:
a. Get its ASCII value.
b. Add the ASCII value to the sum.
4. After iterating through all characters, calculate the hash value.
5. Use the modulo operator (%) with 11 on the sum.
6. Return the calculated hash value.
Code:
public class Main
{
public static int customHash(String input) {
int sum = 0;
System.out.println("The value of the sum of all characters that make up the string are:");
for (char character : input.toCharArray()) {
sum += (int) character;
}
System.out.println(sum);
return sum % 11;
}
Result and Discussion: In this experiment we successfully understood the concept of Hashing function
algorithm and designed and implemented a hashing algorithm.
Learning Outcomes: The student will be able to
Course Outcomes: We were able to understand the different hashing algorithms, the different use cases of the
hashing algorithms and learned to implement them.
Conclusion: We have implemented hashing algorithms and understood the concept of hash value algorithms.
We also understood the different applications of hashing algorithms.
Marks
Obtained