JFrame implement bulk get Android Install package security certificate MD5

Source: Internet
Author: User
Tags java se

Today encountered a demand, get all the APK signature MD5, below is I use Java SE implementation of a tool, paste out the core source code, I hope to have a friend in need to help.

The interface is as follows:


Just create the directory where the. apk file is located and the core code is as follows:

public class Readcmdline {private static Md5window window;private static string inputpath;public static void main (String a Rgs[]) {window = new Md5window (); window.setvisible (true); Initwindow ();} private static void Initwindow () {//File directory text box Window.getfilepathbutton (). addActionListener (New ActionListener () {@ overridepublic void actionperformed (ActionEvent arg0) {JFileChooser JFC = new JFileChooser (); Jfc.setfileselectionmode ( jfilechooser.files_and_directories); Jfc.showdialog (new JLabel (), "select"); File File = Jfc.getselectedfile (); Notdirectoryexcute (file);}}); /Start Run button Window.getbeginbutton (). addActionListener (New ActionListener () {@Overridepublic void actionperformed ( ActionEvent arg0) {InputPath = window.getjtextfiled (); if (InputPath! = null &&! "). Equals (Inputpath.trim ())) {Notdirectoryexcute (new File (InputPath));}}); /Empty Results button Window.getclearbutton (). addActionListener (New ActionListener () {@Overridepublic void actionperformed ( ActionEvent arg0) {Window.settextarea ("");}});} /** * Determine if it is a directoryIf not then execute * * @param file */public static void Notdirectoryexcute (file file) {if (File.isdirectory ()) {InputPath = file.ge Tabsolutepath (); window.setjtextfiled (InputPath); file[] Fiels = File.listfiles (); for (int i = 0; i < fiels.length; i++) {String abspath = Fiels[i].getabsolutepath (); if (Abspath.contains (". apk")) {Excute (Abspath);}}} else {joptionpane.showmessagedialog (window, "Please select Directory");}} /** * Core Logic * * @param abspath */public static void Excute (String abspath) {//1, read Cert.rsa file from. apk String appName = Abspat H.substring (Abspath.lastindexof ("_") + 1,abspath.lastindexof (".")); try {if (abspath! = null) {Readzipfile (Abspath)}} catch (Exception e) {e.printstacktrace ();} 2. Execute keytool command to get md5process process = null; list<string> processlist = new arraylist<string> (); try {process = Runtime.getruntime (). EXEC ("Keytool- Printcert-file D:/test/cert. RSA "); BufferedReader input = new BufferedReader (New InputStreamReader (Process.getinputstream ())); String line = "", while (line = input.ReadLine ()) = null) {Processlist.add (line);} Input.close ();} catch (IOException e) {e.printstacktrace ();} Filter content for (String line:processlist) {if (Line.contains ("MD5")) {Window.settextarea (Window.gettextarea () + String.Format ("%-30s", AppName) + Line.trim () + "\ n");}}}  /** * Read Compressed file contents * * @param file Compressed path * @throws Exception */public static void Readzipfile (String file) throws Exception {ZipFile ZF = new ZipFile (file); InputStream in = new Bufferedinputstream (new FileInputStream (file)); Zipinputstream Zin = new Zipinputstream (in); File OutFile = new file ("D:\\test\\cert. RSA "); OutputStream out = new FileOutputStream (outFile); InputStream rsastream = Zf.getinputstream (Zf.getentry (" Meta-inf/cert. RSA ")) (byte[] buf1 = new Byte[1024];int len;while (len = Rsastream.read (buf1)) > 0) {out.write (buf1, 0, Len);} Rsastream.close (); Out.close (); In.close (); Zin.closeentry ();}}

JFrame implement bulk get Android Install package security certificate MD5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.