A java decryption method, how to use php to achieve ah, kneel to beg Daniel ~

involves other people"s code problems, so the source code is deleted

Feb.27,2021

A cursory glance shows that there are only three key things

  1. RSA
  2. Base64
  3. gzip

find the php libraries of these three and we are done

sort out the flow of this program:

  1. convert the string parameter data to JSON object, and use the variable json to receive the result;
  2. decode json ["d_head"] using BASE64, using the variable ecryptData . ) receive the result
  3. decrypt ecryptData using the RSA algorithm, use the variable datas to receive;
  4. decompress datas using gzip , use the variable b3 to receive;
  5. convert b3 from byteArray to T type object, using the variable obj to receive;
  6. returns obj .

what you need to do is to implement each of the above steps separately in php, rather than trying to implement the sum of all the above steps in php at the same time. When implementing, you can print out the variables that store the results of each step of the java version of the algorithm, json , ecryptData , datas , b3 and obj . If you implement the php version of the algorithm for the same input, the output of each step is the same as the java version. When you say you can't decompress, there may be two reasons:

  1. the results of the previous steps (steps 1, 2 and 3) ( json , ecryptData and datas ) are incorrect;
  2. your decompression algorithm is different from the java version.

as long as you ensure that, for the same input, the datas of your php version of the algorithm is exactly the same as the datas of the java version of the algorithm, and the decompression algorithm of your php version uses the same behavior as the decompression function used by the java version of the algorithm, there will be absolutely no error in this step of decompression, and the result is correct after decompression.


@ Untitled this big brother, it is true that he has a trick here, that is, he returned two strings head and body , respectively head and body base64_decode () , and then only decrypted head to get RsaHead and < code . He was like this, and later I found out after a close look at the source code of java.

Menu