Android client mobile phone number Decryption Method

Source: Internet
Author: User

Because the user's contact phone number is an image when the second-hand house information is crawled on the page of 58 city, my horizontal relationship cannot be well identified, so it is easier to capture the android client, previously, it was good. Recently, I found that my mobile phone number was encrypted after I upgraded to 1.3.0.0, So I directly decompiled its android client and found that it uses des encryption, and the Encrypted key is easily obtained, the decryption method is shown below. (Des encryption and decryption is relatively simple)
 
Java code
Import java. security. SecureRandom;
Import javax. crypto. Cipher;
Import javax. crypto. SecretKey;
Import javax. crypto. SecretKeyFactory;
Import javax. crypto. spec. DESKeySpec;
 
Public class Decode458 {
Static byte [] key = null; // if necessary, decompile the key to the 58 client.

Public static void main (String [] args) throws Exception {
System. out. println (new String (Decode458.decode (Decode458.convertHexString ("002e674177ae8239982087dcb2e6a99b "))));
System. out. println (Decode458.toHexString (Decode458.encode ("13219863008". getBytes ())));
}

Public static byte [] decode (byte [] paramArrayOfByte ){
Try {
SecureRandom localSecureRandom = new SecureRandom ();
DESKeySpec localDESKeySpec = new DESKeySpec (key );
SecretKey localSecretKey = SecretKeyFactory. getInstance ("DES ")
. GenerateSecret (localreceiveyspec );
Cipher localCipher = Cipher. getInstance ("DES ");
LocalCipher. init (2, localSecretKey, localSecureRandom );
Return localCipher. doFinal (paramArrayOfByte );
} Catch (Exception e ){
E. printStackTrace ();
Return null;
}
}

Public static byte [] encode (byte [] paramArrayOfByte ){
Try {
SecureRandom localSecureRandom = new SecureRandom ();
DESKeySpec localDESKeySpec = new DESKeySpec (key );
SecretKey localSecretKey = SecretKeyFactory. getInstance ("DES ")
. GenerateSecret (localreceiveyspec );
Cipher localCipher = Cipher. getInstance ("DES ");
LocalCipher. init (1, localSecretKey, localSecureRandom );
Return localCipher. doFinal (paramArrayOfByte );
} Catch (Exception e ){
E. printStackTrace ();
Return null;
}
}

Public static byte [] convertHexString (String text ){
Byte digest [] = new byte [text. length ()/2];
For (int I = 0; I <digest. length; I ++ ){
String byteString = text. substring (2 * I, 2 * I + 2 );
Int byteValue = Integer. parseInt (byteString, 16 );
Digest [I] = (byte) byteValue;
}
Return digest;
}

Public static String toHexString (byte B []) {
StringBuffer hexString = new StringBuffer ();
For (int I = 0; I <B. length; I ++ ){
String plainText = Integer. toHexString (0xff & B [I]);
If (plainText. length () <2)
PlainText = "0" + plainText;
HexString. append (plainText );
}
Return hexString. toString ();
}
}

Author "jkvast"
 

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.