Verified Owner
Top Fields Constructors Methods
org.jabref.logic.ai.ingestion.util

public final Class FileHasher

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, java.nio.file.Files, .Path, java.security.MessageDigest, .NoSuchAlgorithmException, java.util.Optional, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private static final String
private static final int
private static final Logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static String

Returns:

the hex-encoded string
bytesToHex
(byte[]
the byte array
bytes
)

Converts a byte array to a hexadecimal string.

public static Optional<String>

Returns:

Optional containing the hex-encoded hash of the file, or empty if an error occurred
computeHash
(Path
the path to the file
path
)

Computes the SHA-256 hash of a file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALGORITHMback to summary
private static final String ALGORITHM
BUFFER_SIZEback to summary
private static final int BUFFER_SIZE
LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

FileHasherback to summary
private FileHasher()

Method Detail

bytesToHexback to summary
private static String bytesToHex(byte[] bytes)

Converts a byte array to a hexadecimal string.

Parameters
bytes:byte[]

the byte array

Returns:String

the hex-encoded string

computeHashback to summary
public static Optional<String> computeHash(Path path)

Computes the SHA-256 hash of a file.

Parameters
path:Path

the path to the file

Returns:Optional<String>

Optional containing the hex-encoded hash of the file, or empty if an error occurred