此段代码原先可以获取到微信用户的手机号,现在解密后的信息中没有手机号码了,是什么原因
byte[] encrypData = Base64Utils.decodeFromString(encryptedData);
byte[] ivData = Base64Utils.decodeFromString(iv);
byte[] sessionKey = Base64Utils.decodeFromString(key);
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivData);
String resultString = null;
try {
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
SecretKeySpec keySpec = new SecretKeySpec(sessionKey, "AES");
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
resultString = new String(cipher.doFinal(encrypData), "UTF-8");
} catch (Exception e) {
e.printStackTrace();
}
JSONObject object = JSONObject.parseObject(resultString);
return object.getString("purePhoneNumber");
public Object getPhoneNumber(String session_key, String encryptedData, String iv) throws UnsupportedEncodingException{ String session_key1=session_key.replace(" ","+"); String encryptedData1=encryptedData.replace(" ","+"); String iv1=iv.replace(" ","+"); byte[] encrypData =Base64.getDecoder().decode(encryptedData1); byte[] ivData =Base64.getDecoder().decode(iv1); byte[] keyByte=Base64.getDecoder().decode(session_key1); AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivData); String resultString = null; try { int base = 16; if (keyByte.length % base != 0) { int groups = keyByte.length / base + (keyByte.length % base != 0 ? 1 : 0); byte[] temp = new byte[groups * base]; Arrays.fill(temp, (byte) 0); System.arraycopy(keyByte, 0, temp, 0, keyByte.length); keyByte = temp; } Security.addProvider(new BouncyCastleProvider()); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); SecretKeySpec keySpec = new SecretKeySpec(keyByte, "AES"); cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec); resultString = new String(cipher.doFinal(encrypData), "UTF-8"); } catch (Exception e) { e.printStackTrace(); } JSONObject object = JSONObject.parseObject(resultString); return object.getString("purePhoneNumber"); } //这都运行不了那把小程序砸了