Skip to content

Instantly share code, notes, and snippets.

@barneygale
Created December 8, 2012 16:09
Show Gist options
  • Save barneygale/4240851 to your computer and use it in GitHub Desktop.
Save barneygale/4240851 to your computer and use it in GitHub Desktop.
import java.io.*;
import javax.crypto.*;
import java.util.*;
import javax.crypto.spec.*;
import java.net.*;
public class decrypt {
static String DESpassword = "passwordfile";
static byte[] salt = { 12, -99, 74, -28, 30, -125, 21, -4 };
public static void main(String[] args) {
try {
File lastLogin = new File(args[0]);
PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec(DESpassword.toCharArray()));
Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
cipher.init(2, pbeKey, pbeParamSpec);
DataInputStream dis = new DataInputStream(new CipherInputStream(new FileInputStream(lastLogin), cipher));
String username = dis.readUTF();
String password = dis.readUTF();
dis.close();
System.out.println(username + ", " + password);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment