Can use Java jarfile, jarentry,certificate to get the signature information of Android app
Public classDo {Private Static Final Char[] WJ = "0123456789abcdef". ToCharArray (); /*** Read the signature from the APK * *@paramfile *@return * @throwsIOException*/ PublicString getsignaturesfromapk (file file)throwsIOException {jarfile jarfile=Newjarfile (file); Try{jarentry JE= Jarfile.getjarentry ("Androidmanifest.xml"); byte[] Readbuffer =New byte[8192]; Certificate[] Certs=loadcertificates (Jarfile, je, readbuffer); Jarfile.close (); if(Certs! =NULL) { for(Certificate c:certs) {byteBuffer[] =c.getencoded (); returnK (j (buffer)); } } } Catch(Exception ex) {ex.printstacktrace (); }finally{jarfile.close (); } return NULL; } PrivateString K (byte[] paramarrayofbyte) {StringBuilder Localstringbuilder=NewStringBuilder (3 *paramarrayofbyte.length); inti =paramarrayofbyte.length; for(intj = 0;; J + +) { if(J >=i)returnlocalstringbuilder.tostring (). toUpperCase (); intK = 0xFF &Paramarrayofbyte[j]; Localstringbuilder.append (wj[(k>> 4)]); Localstringbuilder.append (wj[(k& 0xF)]); } } Public byte[] J (byte[] paramarrayofbyte) { Try{messagedigest localmessagedigest= Messagedigest.getinstance ("MD5"); Localmessagedigest.update (Paramarrayofbyte); byte[] Arrayofbyte =localmessagedigest.digest (); returnArrayofbyte; } Catch(nosuchalgorithmexception localnosuchalgorithmexception) {localnosuchalgorithmexception.printstacktrace () ; } return NULL; } /*** Load Signature * *@paramJarfile *@paramJE *@paramReadbuffer *@return */ Privatecertificate[] Loadcertificates (jarfile jarfile, jarentry je,byte[] readbuffer) {InputStream is=NULL; Try{ is=Jarfile.getinputstream (JE); while(Is.read (readbuffer, 0, readbuffer.length)! =-1) { }//is.close (); returnJe! =NULL? Je.getcertificates ():NULL; } Catch(IOException e) {e.printstacktrace (); }finally{ if(Is! =NULL){ Try{is.close (); } Catch(IOException e) {//TODO auto-generated Catch blockE.printstacktrace (); } } } return NULL; }}
Get your Android app's signature