Cipherpack v1.2.0-dirty
A Cryprographic Stream Processor
Static Public Member Functions | List of all members
org.cipherpack.Cipherpack.HashUtil Class Reference

Hash utility functions to produce a hash file compatible to sha256sum as well as to produce the hash value itself for validation. More...

Collaboration diagram for org.cipherpack.Cipherpack.HashUtil:

Static Public Member Functions

static boolean appendToFile (final String outFileName, final String hashedFile, final String hashAlgo, final byte[] hashValue)
 Append the hash signature to the text file out_file. More...
 
static byte[] calc (final String algo, final ByteInStream source)
 Return the calculated hash value using given algo name and byte input stream. More...
 
static byte[] calc (final String algo, final String path_or_uri, final long bytes_hashed[])
 Return the calculated hash value using given algo name and the bytes of a single file or all files if denoting a directory. More...
 
static byte[] calc (final String algo, final String path_or_uri, final long bytes_hashed[], final long timeoutMS)
 Return the calculated hash value using given algo name and the bytes of a single file or all files if denoting a directory. More...
 
static String fileSuffix (final String algo)
 Return a lower-case file suffix used to store a sha256sum compatible hash signature w/o dot and w/o dashes. More...
 

Detailed Description

Hash utility functions to produce a hash file compatible to sha256sum as well as to produce the hash value itself for validation.

Definition at line 261 of file Cipherpack.java.

Member Function Documentation

◆ fileSuffix()

static String org.cipherpack.Cipherpack.HashUtil.fileSuffix ( final String  algo)
static

Return a lower-case file suffix used to store a sha256sum compatible hash signature w/o dot and w/o dashes.

Definition at line 263 of file Cipherpack.java.

Here is the caller graph for this function:

◆ appendToFile()

static boolean org.cipherpack.Cipherpack.HashUtil.appendToFile ( final String  outFileName,
final String  hashedFile,
final String  hashAlgo,
final byte[]  hashValue 
)
static

Append the hash signature to the text file out_file.

The hash signature is composed as follows

  • hash algo name
  • space
  • hash value
  • space
  • * to denote binary processing
  • hashed file name

The hash signature is similar to sha256sum output, but the added hash algo name upfront.

Parameters
outFileNamethe text file to append hash signature of hashed_file.
hashedFilethe file of the hash signature
hashAlgothe hash algo name used
hashValuethe hash value of hashed_file
Returns
true if successful, otherwise false

Definition at line 286 of file Cipherpack.java.

Here is the caller graph for this function:

◆ calc() [1/3]

static byte[] org.cipherpack.Cipherpack.HashUtil.calc ( final String  algo,
final ByteInStream  source 
)
static

Return the calculated hash value using given algo name and byte input stream.

Parameters
algothe hash algo name
sourcethe byte input stream
Returns
the calculated hash value or null in case of error

Definition at line 313 of file Cipherpack.java.

Here is the caller graph for this function:

◆ calc() [2/3]

static byte[] org.cipherpack.Cipherpack.HashUtil.calc ( final String  algo,
final String  path_or_uri,
final long  bytes_hashed[],
final long  timeoutMS 
)
static

Return the calculated hash value using given algo name and the bytes of a single file or all files if denoting a directory.

Parameters
algothe hash algo name
path_or_urigiven path or uri, either a URI denoting a single file, a single file path or directory path for which all files (not symbolic links) are considered
bytes_hashedreturns overall bytes hashed
timeoutMSin case path_or_uri refers to an URI, timeout is being used as maximum duration in milliseconds to wait for next bytes. Defaults to 20_s.
Returns
the calculated hash value or nullptr in case of error
See also
calc(String, String, long[])

Definition at line 327 of file Cipherpack.java.

◆ calc() [3/3]

static byte[] org.cipherpack.Cipherpack.HashUtil.calc ( final String  algo,
final String  path_or_uri,
final long  bytes_hashed[] 
)
static

Return the calculated hash value using given algo name and the bytes of a single file or all files if denoting a directory.

This variant uses a 20_s timeout to wait for next bytes.

Parameters
algothe hash algo name
path_or_urigiven path or uri, either a URI denoting a single file, a single file path or directory path for which all files (not symbolic links) are considered
bytes_hashedreturns overall bytes hashed
Returns
the calculated hash value or nullptr in case of error
See also
calc(String, String, long[], long)

Definition at line 341 of file Cipherpack.java.


The documentation for this class was generated from the following file: