Skip to content

Instantly share code, notes, and snippets.

@Lobbyra
Last active August 14, 2023 19:27
Show Gist options
  • Save Lobbyra/4ada42b19a5ff146b50024672adbf751 to your computer and use it in GitHub Desktop.
Save Lobbyra/4ada42b19a5ff146b50024672adbf751 to your computer and use it in GitHub Desktop.
This is a secret code for a job form
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/*
* This is the output :
* Word : accordions
* Hashed : 335cdf4567915d3831adf0aca249bfb802a3a16d66d438ec92d654ab62f4aa45
*/
public class App {
static final String wordlistURL = "https://raw.githubusercontent.com/lorenbrichter/Words/master/Words/fr.txt";
public static String sha256(final String base) throws NoSuchAlgorithmException, UnsupportedEncodingException {
final MessageDigest digest = MessageDigest.getInstance("SHA-256");
final byte[] hash = digest.digest(base.getBytes("UTF-8"));
final StringBuilder hexString = new StringBuilder();
for (int i = 0; i < hash.length; i++) {
final String hex = Integer.toHexString(0xff & hash[i]);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return (hexString.toString());
}
public static void main(String[] args) throws Exception {
final URL url = new URL(wordlistURL);
final HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream())
);
String inputLine;
String hashedWord;
while ((inputLine = in.readLine()) != null) {
inputLine = inputLine.toLowerCase();
if (inputLine.length() == 10) {
hashedWord = sha256(inputLine);
if (hashedWord.indexOf("fb80") != -1) {
System.out.println("Word : " + inputLine);
System.out.println("Hashed : " + hashedWord);
return ;
}
}
}
in.close();
con.disconnect();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment