如果我创建一个 messagedigist 然后用字节值更新它,更改顺序更改哈希的输出
例子
BigInteger d_KGC = new BigInteger("773182302672421767750165305491852205951657281488");
BigInteger r_KGC = new BigInteger("1354751385705862203270732046669540660812388894970");
String C_ID = "id_c";
hash_h_c.update(r_KGC.toByteArray());
hash_h_c.update(d_KGC.toByteArray());
hash_h_c.update(C_ID.getBytes());
BigInteger h_c = new BigInteger(1, hash_h_c.digest());
System.out.println(h_c);
输出
49379655005878985488511725474312101658690290667242109419474456484341588492679
但是,如果我更改更新顺序,例如:
hash_h_c.update(d_KGC.toByteArray());
hash_h_c.update(r_KGC.toByteArray());
hash_h_c.update(C_ID.getBytes());
BigInteger h_c = new BigInteger(1, hash_h_c.digest());
System.out.println(h_c);
输出
74931638923759682675388497216517269416730536285702508607436092426996570518730
总的结果不应该是一样的吗?或更改顺序导致不同的哈希