Skip to content

Commit

Permalink
Switch class bytecode hashing implementation from md5 to sha256
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Feb 11, 2024
1 parent de4d5f8 commit 561cf88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ClassFile(

private String computeHash(InputStreamSupplier inputStreamSupplier) throws IOException {
try (InputStream inputStream = inputStreamSupplier.get()) {
return DigestUtils.md5Hex(inputStream);
return DigestUtils.sha256Hex(inputStream);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ClassFileTest {
public void getHashComputesHashOfFile() throws Exception {
ClassFile classFile = classFileHelper.createWithContent(PATH_TO_CLASS_FILE, "the content of the file");

assertEquals("7e47820975c51a762e63caa95cc76e45", classFile.getHash());
assertEquals("7b7f48e1c0e847133d8881d5743d253756bf44e490e2252556ad4816a0a77b67", classFile.getHash());
}

@Test
Expand All @@ -29,7 +29,7 @@ public void getHashReturnsConsistentHashWhenInvokedTwice() throws Exception {
String hash1 = classFile.getHash();
String hash2 = classFile.getHash();

assertEquals("d10b4c3ff123b26dc068d43a8bef2d23", hash1);
assertEquals("e0ac3601005dfa1864f5392aabaf7d898b1b5bab854f1acb4491bcd806b76b0c", hash1);
assertEquals(hash1, hash2);
}
}

0 comments on commit 561cf88

Please sign in to comment.