android用戶端手機號碼解密方法

來源:互聯網
上載者:User

由於58同城在頁面上抓取二手房資訊的時候,使用者的聯絡電話是圖片的,本人水平關係無法進行很好的識別,所以轉為抓取其android用戶端比較容易,之前都是好好的,最近發現其升級到1.3.0.0後手機號碼進行了加密,所以直接反編譯其android用戶端,查到其用的是des加密,而且加密的key很容易就拿到,下面貼出解密方法。(des加解密比較簡單下面貼出來)
 
Java代碼 
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; //這個key如果有需要請反編譯58用戶端擷取這裡不便貼出 
     
    public static void main(String[] args) throws Exception { 
        System.out.println(new String(Decode458.decode(Decode458.convertHexString("002E674657AE8239982087DCB2E6A99B")))); 
        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(localDESKeySpec); 
            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(localDESKeySpec); 
            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(); 
    } 

作者“jkvast”
 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.