See the following steps.
1. Accept a user password of length N as keyboard input to your program. You can determine your own length N.
2. Compute the hash of the password from step 1.
Your hash function H() is simply the checksum. (See Assignment 2)
3. Now you become an attacker and try to find the password of length N.
Try every combination of length N password and for each combination, compute the hash and compare to the hash of the password from step 2.
Measure execution time.
4. Now let’s reinforce our password using the password salt. Accept an arbitrary non-negative integer number as keyboard input to your program.
5. Compute the hash of the concatenated password salt and password from step 4 and step 1. To compute the password salt portion of the checksum, you can treat the entire password salt as EITHER a single integer OR multiple one-byte integers.
6. Now you become an attacker and try to find the concatenated password salt and password.
Try every combination of an arbitrary non-negative integer number and length N password and for each combination, compute the hash and compare to the hash from step 5.
Measure execution time.
NOTE: your program should have separate functions for the checksum and the two dictionary attacks with and without the password salt by the attacker.
in python | c++ any please
Here is the assignment 2 which has checkSum function ….
#include
using namespace std;
//checksum function to add all the characters of the string in ASCII codes
long checksum(string input)
{
//here we change the string value to ASCII value
long value = 0;
for (char a : input)
value+= (int)a;
return value;
}
// function for the message modification by the attacker.
string modification(string input)
{
string total = “”;
for (char a : input)
{
total += min(126, a + 1);
}
return total;
}
int main()
{
//here we accept the message from the user
string message;
//asking user input
cout << "Pease enter the message: ";
//storing the user input
cin >> message;
//here we accept secret key from the user
string secretKey;
//asking the secret key
cout << "Please enter the sender secret key: ";
//storing the secret key
cin >> secretKey;
string finalMessage= secretKey + message;
//here calling the function checksum
long sender_checksum = checksum(finalMessage);
// here we accept attack secret from user
string attackKey;
cout << "Please enter the attacker secret key: ";
cin >> attackKey;
// here we modify original message from calling above function
string modifiedMessage = modification(message);
// here is the final attacker msg
string finalattackMessage = attackKey + modifiedMessage;
//here we compute the checksum
long attackerChecksum = checksum(finalattackMessage);
// here concatenate secret of sender and modified msg
string finalsenderModified = secretKey + modifiedMessage;
// here compute the checksum
long sendermodifiedChecksum = checksum(finalsenderModified);
cout << "The sender original checksum is: " << sender_checksum << "n";
cout << "The attacker checksum is: " << attackerChecksum<< "n";
cout << "The sender modified checksum is: " << sendermodifiedChecksum << "nn";
//compare chekcsum from steps 7 and 6
if (attackerChecksum == sendermodifiedChecksum)
cout << "The attacker checksum and sender modified checksum are equal";
else
cout << "The attacker checksum and sender modified checksum are not equal";
cout << "nn";
//compare checksums from steps 3 and 6
if (sender_checksum == attackerChecksum)
cout << "The original sender checksum and attacker checksum are equal";
else
cout << "The original sender checksum and attacker checksum are not equal"<<"n";
//returns nothing
return 0;
}