Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java BigInteger总是相同的_Java_Md5_Biginteger_Message Digest - Fatal编程技术网

Java BigInteger总是相同的

Java BigInteger总是相同的,java,md5,biginteger,message-digest,Java,Md5,Biginteger,Message Digest,我试图为您从我的Jar上传到我的服务器的每个文件创建一个唯一的名称。我正在使用MessageDigestMD5类来创建,但不幸的是,我总是得到相同的名称 BufferedImage buffImg = ImageIO.read(imageEntry); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ImageIO.write(buffImg, Utils.getExtensionNoDot(imageEntry

我试图为您从我的Jar上传到我的服务器的每个文件创建一个唯一的名称。我正在使用
MessageDigest
MD5类来创建,但不幸的是,我总是得到相同的名称

BufferedImage buffImg = ImageIO.read(imageEntry);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ImageIO.write(buffImg, Utils.getExtensionNoDot(imageEntry.getName()), outputStream);
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(outputStream.toByteArray());
BigInteger bigInt = new BigInteger(1,md.digest());
String md5 = bigInt.toString(16);

我的md5与往常一样,通过打印和验证结果,我知道我的MessageDigest总是不同的,但结果总是相同的BigInt。

你使用BigInteger的构造函数时出错了。见:或者实施他给我的一个解决方案,但结果总是一样的,我不认为问题一定在别处@Koshinae数字
1
在每一个基数中都是相同的,您使用的构造函数不正确。是时候找个借口了。@Tom好的,我会试着深入探究这个问题您使用的BigInteger的构造函数不正确。见:或者实施他给我的一个解决方案,但结果总是一样的,我不认为问题一定在别处@Koshinae数字
1
在每一个基数中都是相同的,您使用的构造函数不正确。是时候进行分析了。@Tom好的,我将尝试深入研究这个问题