Skip to content

Commit

Permalink
Add convenience method for byte array hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
ukengineer925 committed Mar 21, 2023
1 parent e25a082 commit 37bdb03
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/emissary/kff/KffDataObjectHandler.java
Expand Up @@ -67,6 +67,21 @@ public KffDataObjectHandler(boolean truncateKnownData, boolean setFormOnKnownDat
this.setFileTypeOnKnown = setFileTypeOnKnown;
}

/**
* Convenience memthod to hash a byte array of data.
*
* @param data to hash
* @param name the name of the data (for reporting)
* @param prefix prepended to hash name entries
* @return parameter entries suitable for a BaseDataObject
* @throws IOException if the data can't be read
* @throws NoSuchAlgorithmException if the checksum can't be computed
*/
public Map<String, String> hashData(final byte[] data, final String name, String prefix)
throws IOException, NoSuchAlgorithmException {
return hashData(SeekableByteChannelHelper.memory(data), name, prefix);
}

/**
* Compute the configure hashes and return as a map Also include entries indicating the know file or duplicate file
* status if so configured
Expand Down

0 comments on commit 37bdb03

Please sign in to comment.