Browse Source

Commit6

master
Michal Malawski 2 years ago
parent
commit
e43ae56c3e

BIN
out/production/PROG3PASSWORT/Helpers.class View File


BIN
out/production/PROG3PASSWORT/Main.class View File


+ 4
- 0
out/production/PROG3PASSWORT/passwd.txt View File

hofmannol
2df372ddeafdf65908ddda48799d6f21
wimmerma
eb9b41a390c3a252aff0454e8df16f75

+ 3
- 2
src/Helpers.java View File

import java.io.*; import java.io.*;
import java.math.BigInteger; import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.ArrayList; import java.util.ArrayList;
// Rückgabe als Hex-Zeichenkette // Rückgabe als Hex-Zeichenkette
public static String getHash(String w) { public static String getHash(String w) {
try { try {
byte[] bytesOfMessage = w.getBytes("UTF-8");
byte[] bytesOfMessage = w.getBytes(StandardCharsets.UTF_8);
MessageDigest md = MessageDigest.getInstance("MD5"); MessageDigest md = MessageDigest.getInstance("MD5");
byte[] thedigest = md.digest(bytesOfMessage); byte[] thedigest = md.digest(bytesOfMessage);
return String.format("%032x", new BigInteger(1, thedigest)); return String.format("%032x", new BigInteger(1, thedigest));
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
} catch (NoSuchAlgorithmException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;

+ 1
- 1
src/Main.java View File

// String login = s.next(); // String login = s.next();
// System.out.println("Passwort:"); // System.out.println("Passwort:");
// String pwd = s.next(); // String pwd = s.next();
// s. close();
s. close();


Helpers.readTextdatei("src/passwd.txt"); Helpers.readTextdatei("src/passwd.txt");
Helpers.writeTextdatei("src/passwd.txt", Helpers.readTextdatei("src/passwd.txt")); Helpers.writeTextdatei("src/passwd.txt", Helpers.readTextdatei("src/passwd.txt"));

Loading…
Cancel
Save