JFrame implement bulk get Android Install package security certificate MD5

Source: Internet
Author: User
Tags java se

Meet a demand today. Get the MD5 of all apk signatures. Here is a tool that I implemented using Java SE. Paste out the core source code. I hope to help the friends who need them.

The interface is as follows:


Just need to make the. apk file in the same folder as you can, the core code such as the following:

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 folder 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 running Buttonwindow.getbeginbutton (). addActionListener (New ActionListener () {@Overridepublic void actionperformed ( ActionEvent arg0) {InputPath = window.getjtextfiled (); if (InputPath! = null &&! "). Equals (Inputpath.trim ())) {Notdirectoryexcute (new File (InputPath));}}); /empty result Buttonwindow.getclearbutton (). addActionListener (New ActionListener () {@Overridepublic void actionperformed ( ActionEvent arg0) {Window.settextarea ("");}});} /*** Infer if it is a folder, assuming it is not, run * * @param file */public static void Notdirectoryexcute (file file) {if (File.isdirectory ()) {InputPath = File.getabsolutepath (); 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 Folder");}} /** * 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. Run 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

Related Article

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.