search

Home  >  Q&A  >  body text

Convert JAVA method to the same functionality in PHP

Because I only know PHP language, I can’t understand a Java method, and I don’t know how to implement it with PHP. Could you please give me some advice:
java source code is as follows:

    MessageDigest md5 = MessageDigest.getInstance("MD5");
        BASE64Encoder base64en = new BASE64Encoder();
        // 加密后的字符串
        String newstr = base64en.encode(md5.digest(str.getBytes("utf-8")));

How to implement the above method using PHP?

为情所困为情所困2755 days ago875

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-07-01 09:14:01

    $newstr = base64_encode(md5($str,true));

    reply
    0
  • 学习ing

    学习ing2017-07-01 09:14:01

    $newstr = base64_encode(md5(mb_convert_encoding($str,'utf-8')))

    reply
    0
  • Cancelreply