Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c85a8ad

Browse filesBrowse files
committed
Make sure the computed hash is used.
1 parent 53e397b commit c85a8ad
Copy full SHA for c85a8ad

File tree

Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed
Open diff view settings
Collapse file

‎highcpu/src/main/java/com/github/chrishantha/sample/highcpu/HashingWorker.java‎

Copy file name to clipboardExpand all lines: highcpu/src/main/java/com/github/chrishantha/sample/highcpu/HashingWorker.java
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class HashingWorker implements Runnable {
2424
private final String algorithm;
2525
private final long length;
2626

27+
private byte[] lastComputedHash;
28+
2729
public HashingWorker(long length, String algorithm) {
2830
this.length = length;
2931
this.algorithm = algorithm;
@@ -48,6 +50,11 @@ public void run() {
4850

4951
// Hash
5052
digest.update(data.getBytes());
53+
byte[] computedHash = digest.digest();
54+
if (lastComputedHash != null && computedHash.length != lastComputedHash.length) {
55+
throw new IllegalStateException("Is the hash computation correct??");
56+
}
57+
lastComputedHash = computedHash;
5158
}
5259
}
5360
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.