Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import javax.crypto.*;
- import javax.crypto.spec.*;
- import java.util.*;
- import javax.swing.JOptionPane;
- public class Lastlogin {
- public static String user = "";
- public static String pass = "";
- public static void main(String[] args) {
- readUsername();
- JOptionPane.showMessageDialog(null, "Username: " + user + "\nPassword: " + pass, "Lastlogin", JOptionPane.INFORMATION_MESSAGE);
- }
- private static void readUsername() {
- try {
- File lastLogin = new File(System.getenv("APPDATA") + "\\.minecraft\\lastlogin");
- Cipher cipher = getCipher(2, "passwordfile");
- DataInputStream dis;
- if (cipher != null) dis = new DataInputStream(new CipherInputStream(new FileInputStream(lastLogin), cipher));
- else dis = new DataInputStream(new FileInputStream(lastLogin));
- user = dis.readUTF();
- pass = dis.readUTF();
- dis.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- private static Cipher getCipher(int mode, String password) throws Exception {
- Random random = new Random(43287234L);
- byte[] salt = new byte[8];
- random.nextBytes(salt);
- PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
- SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec(password.toCharArray()));
- Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
- cipher.init(mode, pbeKey, pbeParamSpec);
- return cipher;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment