Name: Rohan Konde Roll No:52
Name: Rohan Konde Roll No:52
Name: Rohan Konde Roll No:52
Roll No:52
Experiment No. 7
A hash function is a mathematical function that converts a numerical input value into another
compressed numerical value. The input to the hash function is of arbitrary length but output is
always of fixed length.
Values returned by a hash function are called message digest or simply hash values. The
following picture illustrated hash function –
Hash function coverts data of arbitrary length to a fixed length. This process is
often referred to as hashing the data.
In general, the hash is much smaller than the input data, hence hash functions are
sometimes called compression functions.
Since a hash is a smaller representation of a larger data, it is also referred to as a digest.
Hash function with n bit output is referred to as an n-bit hash function. Popular
hash functions generate values between 160 and 512 bits.
Generally for any hash function h with input x, computation of h(x) is a fast operation.
using System;
using System.Security.Cryptography;
using System.Text;
class Class1
{
static void Main()
{
//This hash value is produced from "This is the original message!"
//using SHA256.
byte[] sentHashValue = { 185, 203, 236, 22, 3, 228, 27, 130, 87, 23, 244, 15,
87, 88, 14, 43, 37, 61, 106, 224, 81, 172, 224, 211, 104, 85, 194, 197, 194, 25, 12 0,
217 };
byte[] compareHashValue;
If the two hash values match, this code displays the following to the
console: Console
Copy
The hash codes match.
If they do not match, the code displays the
following: Console
Copy
The hash codes do not match.