不同的字节数组具有相同的BASE64编码字符串
创始人
2025-01-08 22:00:12
0

以下是一个使用Java编写的示例代码,可以找出具有相同BASE64编码字符串的不同字节数组:

import java.util.Base64;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {
        // 创建一个Map来存储BASE64编码字符串和对应的字节数组
        Map map = new HashMap<>();

        // 待测试的不同字节数组
        byte[] byteArray1 = "Hello".getBytes();
        byte[] byteArray2 = "World".getBytes();
        byte[] byteArray3 = "Different".getBytes();

        // 将字节数组转换为BASE64编码字符串并存入map中
        String base64String1 = Base64.getEncoder().encodeToString(byteArray1);
        map.put(base64String1, byteArray1);

        String base64String2 = Base64.getEncoder().encodeToString(byteArray2);
        map.put(base64String2, byteArray2);

        String base64String3 = Base64.getEncoder().encodeToString(byteArray3);
        map.put(base64String3, byteArray3);

        // 遍历map,找出具有相同BASE64编码字符串的不同字节数组
        for (Map.Entry entry : map.entrySet()) {
            String base64String = entry.getKey(); // BASE64编码字符串
            byte[] byteArray = entry.getValue(); // 对应的字节数组

            // 遍历map的其他键值对,查找具有相同BASE64编码字符串的不同字节数组
            for (Map.Entry otherEntry : map.entrySet()) {
                String otherBase64String = otherEntry.getKey();
                byte[] otherByteArray = otherEntry.getValue();

                // 排除自身和相同的BASE64编码字符串
                if (!base64String.equals(otherBase64String) && byteArray.length != otherByteArray.length) {
                    System.out.println("找到具有相同BASE64编码字符串的不同字节数组:");
                    System.out.println("字节数组1: " + new String(byteArray));
                    System.out.println("字节数组2: " + new String(otherByteArray));
                    System.out.println("BASE64编码字符串: " + base64String);
                    break;
                }
            }
        }
    }
}

这段代码首先创建了一个Map来存储BASE64编码字符串和对应的字节数组。然后,使用Base64类将字节数组转换为BASE64编码字符串,并将其作为键存入map中。接下来,遍历map,查找具有相同BASE64编码字符串的不同字节数组。在内部遍历中,首先排除自身和相同的BASE64编码字符串,然后比较字节数组的长度,如果不相等,则找到了具有相同BASE64编码字符串的不同字节数组。最后,打印出找到的字节数组和对应的BASE64编码字符串。

相关内容

热门资讯

这一问题亟待解决!xpoker... 这一问题亟待解决!xpoker透视辅助(透视)余干六副辅助(真是存在有辅助平台)-哔哩哔哩1、每一步...
透视工具!aapoker安装包... 透视工具!aapoker安装包怎么使用(透视)湖湘互娱牛牛(确实有辅助软件)-哔哩哔哩1、完成湖湘互...
透视好友!pokemmo脚本最... 透视好友!pokemmo脚本最新版(透视)来几局是正规平台吗(竟然是真的辅助辅助器)-哔哩哔哩1、这...
透视总结!sohoo poke... 透视总结!sohoo poker辅助器(透视)三哥玩十三张辅助器(本来存在有辅助辅助器)-哔哩哔哩;...
透视规律!wepoker辅助是... 透视规律!wepoker辅助是真的假的(透视)大唐麻将辅助软件(都是真的是有辅助下载)-哔哩哔哩1、...
透视数据!竞技联盟辅助(透视)... 透视数据!竞技联盟辅助(透视)杭麻圈辅助工具(果然是有辅助插件)-哔哩哔哩1)杭麻圈辅助工具辅助插件...
透视存在!wepoker黑侠辅... 透视存在!wepoker黑侠辅助器(透视)雀神广东麻将推倒胡辅助器下载(竟然有辅助app)-哔哩哔哩...
据目击者称!pokemmo手机... 据目击者称!pokemmo手机版透视脚本(透视)授权二厅辅助(果然真的是有辅助修改器)-哔哩哔哩1、...
透视总结!werplan免费挂... 透视总结!werplan免费挂下载(透视)新蛮王辅助(本来真的是有辅助辅助器)-哔哩哔哩新蛮王辅助是...
近日!aapoker脚本怎么用... 近日!aapoker脚本怎么用(透视)禅游指尖四川修改器(一贯有辅助工具)-哔哩哔哩所有人都在同一条...