How to decrypting the php encrypted string using android?

后端 未结 2 1878
囚心锁ツ
囚心锁ツ 2020-12-17 05:53

Hi I want to decrypting my php encrypted string. My code is

UsingPHP.java

import java.io.UnsupportedEncodingException;
import java.u         


        
2条回答
  •  悲哀的现实
    2020-12-17 06:06

    Well there are two things:

    1. Your encode5t function returns invalid base64 data. If I call encode5t("malavika") then the string ==AUVVVeZhlQhdlRspnUsRW is returned which is not valid base64. The = sign is the padding and is only allowed at the end of the base64-string. I guess what you wanted is:

      function encode5t($value1)
      {
          for($i=0;$i<3;$i++)
          {
              $value1=base64_encode(strrev($value1));
          }
      
          return $value1;
      }
      

      That means you just have to first call strrev and then base64_encode. And in the decode-function you first call base64_decode and then strrev (or the Java counter-parts).

    2. As I've said in the comment, the second Parameter to Base64.decode in your Java-code is expects flags for the base64-processing and not the length of the string. This might for example turn on the URL_SAFE flag which makes it incompatible with the output of PHP's base64_encode.

提交回复
热议问题