CNS 5
CNS 5
SHA-1 encryption
Code:-
#include <iostream>
#include <string>
#include <cstring>
h0 += a;
h1 += b;
h2 += c;
h3 += d;
h4 += e;
}
return result;
}
int main() {
// User input for the message
string message;
cout << "Enter the message to be hashed: ";
getline(cin, message);
// Demonstrate using the hash value (for example, here just displaying the first 8 characters)
cout << "First 8 characters of the hash: " << hash.substr(0, 8) << endl;
return 0;
}
Output:-
Conclusion:-
SHA-1, once widely used, is now considered weak due to vulnerabilities allowing collision
attacks. Stronger hash functions like SHA-256 or SHA-3 are recommended for enhanced
security. Understanding SHA-1 principles is crucial for historical context and cryptographic hash
functions.