Question: Help Grinch to break the password ( Version II ) : Assuming that the Grinch has now discovered the function responsible for generating the final
Help Grinch to break the password Version II: Assuming that the Grinch has now discovered
the function responsible for generating the final authenticating string within the app implementation,
here is the code fragment. This function accepts the users password and a random number as input,
producing the final authenticating string. Grinch has utilized a sniffer and acquired the random number,
which is "drexel", and the resulting authenticating string is dabfddbcf
eddbadaeafabefcdfafd Now, Grinch seeks assistance in
determining the users actual password. The password consists of fewer than digits and comprises
solely numbers.
This is the code I am working with:
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class HashCalculator
public static String calculateCombinedHashString random, String password
Combine the two strings
String combinedString random password;
try
Create a MessageDigest instance for SHA
MessageDigest digest MessageDigest.getInstanceSHA;
Get bytes of the combined string
byte combinedBytes combinedString.getBytes;
Calculate hash bytes
byte hashBytes digest.digestcombinedBytes;
Convert hash bytes to hexadecimal representation
StringBuilder hexString new StringBuilder;
for byte hashByte : hashBytes
Convert each byte to hexadecimal format
String hex Integer.toHexStringxff & hashByte;
if hexlength
hexString.append;
hexString.appendhex;
Return the hexadecimal representation of the hash
return hexString.toString;
catch NoSuchAlgorithmException e
eprintStackTrace;
return null; Return null if hashing algorithm is not found
public static void mainString args
String random "drexel";
String hash dabfddbcfeddbadaeafabefcdfafd;
for int i ; i ; i
String password String.formatd i; Password is less than digits
String combinedHash calculateCombinedHashrandom password;
if combinedHashequalshash
System.out.printlnFound the password: password;
break;
if i
System.out.printlnChecked i passwords so far...";
It is not showing anything of the password, but is showing the count of passwords attempted.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
