Start
This commit is contained in:
commit
290941ad22
4
data/passwd.txt
Normal file
4
data/passwd.txt
Normal file
@ -0,0 +1,4 @@
|
||||
hofmannol
|
||||
2df372ddeafdf65908ddda48799d6f21
|
||||
wimmerma
|
||||
eb9b41a390c3a252aff0454e8df16f75
|
15
src/Credentials.java
Normal file
15
src/Credentials.java
Normal file
@ -0,0 +1,15 @@
|
||||
public class Credentials {
|
||||
private String login;
|
||||
private String hash;
|
||||
|
||||
public Credentials(String login, String password) {
|
||||
for (String line:
|
||||
Helpers.readTextdatei("data/passwd.txt")) {
|
||||
System.out.println(line);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean valid() {
|
||||
return false;
|
||||
}
|
||||
}
|
55
src/Helpers.java
Normal file
55
src/Helpers.java
Normal file
@ -0,0 +1,55 @@
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Helpers {
|
||||
|
||||
// Lesen einer Textdatei in ein Stringarray
|
||||
public static String[] readTextdatei(String name) {
|
||||
String line;
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
try {
|
||||
FileReader fr = new FileReader(name);
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
while ((line = br.readLine()) != null)
|
||||
result.add(line);
|
||||
br.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result.toArray(new String[]{});
|
||||
}
|
||||
|
||||
// Schreiben eines Stringarray in eine Textdatei
|
||||
public static void writeTextdatei(String name, String[] lines) {
|
||||
try {
|
||||
FileWriter fw = new FileWriter(name);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
PrintWriter pw = new PrintWriter(bw);
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
pw.println(lines[i]);
|
||||
pw.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Berechnen des Hashwerts zu einem String und
|
||||
// Rückgabe als Hex-Zeichenkette
|
||||
public static String getHash(String w) {
|
||||
try {
|
||||
byte[] bytesOfMessage = w.getBytes("UTF-8");
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] thedigest = md.digest(bytesOfMessage);
|
||||
return String.format("%032x", new BigInteger(1, thedigest));
|
||||
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
5
src/Main.java
Normal file
5
src/Main.java
Normal file
@ -0,0 +1,5 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user