首页 > 代码库 > java中异或加密

java中异或加密

static String simple_xor(String base_data, String encrypt_key) throws UnsupportedEncodingException {
        StringBuffer xor = new StringBuffer("");
        int base_len = base_data.length();
        int encrypt_len = encrypt_key.length();
        int j = 0;
        for (int i = 0; i < base_len; i++) {
            xor.append((char) (base_data.charAt(i) ^ encrypt_key.charAt(j)));
            j = (++j) % encrypt_len;
        }
        return xor.toString();
    }

java中异或加密