Can anyone convert Java's XOR encryption into PHP's?
给你微笑
给你微笑 2023-06-02 17:13:42
0
1
319
import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; public class Main { public static void main(String[] args) { String s = new String("2342356`中户人民@¥#%&*()-=|+_}{[]/.,;:,.>》》"); String enc = encrypt(s, "f8ee541137a2aa381abaac17886653ba"); System.out.println("加密的:" + enc); } private static String convert(String inStr, String secretKey) { char[] a = inStr.toCharArray(); char[] s = rmRepeated(secretKey).toCharArray(); for (int i = 0; i>4)); sb.append(hexString.charAt((bytes[i] &0x0f) >>0)); } r=sb.toString(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return r; } public static String encrypt(String inStr, String secretKey) { String hexStr=convert(inStr, secretKey); return encode(hexStr); } }

The php I wrote

public function encrypt(){ return bin2hex($this->convert1('2342356`中户人民@¥#%&*()-=|+_}{[]/.,;:,.>》》','f8ee541137a2aa381abaac17886653ba')); } public function convert($str,$app_key){ $a = str_split($str); $s = str_split(implode(array_unique(str_split($app_key)))); for ($i = 0; $i
      


The encrypted content returned by the two is inconsistent. It seems to be a Chinese XOR problem

给你微笑
给你微笑

reply all (1)
八哥

Download a PHP-Java-bridge_Xxxx_j2ee plug-in, install Java8, and then deploy the plug-in to directly execute Java code in PHP

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!