ssdeep

package
v1.4.4-alpha1202-diff-... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0, BSD-3-Clause, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyHash is returned when no hash string is provided for scoring.
	ErrEmptyHash = errors.New("empty string")

	// ErrInvalidFormat is returned when a hash string is malformed.
	ErrInvalidFormat = errors.New("invalid ssdeep format")
)
View Source
var (
	// ErrFileTooSmall is returned when a file contains too few bytes.
	ErrFileTooSmall = errors.New("did not process files large enough to produce meaningful results")
	// ErrBlockSizeTooSmall is returned when a file can't produce a large enough block size.
	ErrBlockSizeTooSmall = errors.New("unable to establish a sufficient block size")
	// ErrZeroBlockSize is returned if we fail to establish a non-zero block size.
	ErrZeroBlockSize = errors.New("Reached zero block size, unable to compute hash")
)
View Source
var (

	// Force calculates the hash on invalid input
	Force = false
)

Functions

func Distance

func Distance(hash1, hash2 string) (score int, err error)

Distance computes the match score between two fuzzy hash signatures. Returns a value from zero to 100 indicating the match score of the two signatures. A match score of zero indicates the signatures did not match. Returns an error when one of the inputs are not valid signatures.

func FuzzyBytes

func FuzzyBytes(buffer []byte) (string, error)

FuzzyBytes computes the fuzzy hash of a slice of byte. It is the caller's responsibility to append the filename, if any, to result after computation. Returns an error when ssdeep could not be computed on the buffer.

func FuzzyFile

func FuzzyFile(f *os.File) (string, error)

FuzzyFile computes the fuzzy hash of a file using os.File pointer. FuzzyFile will computes the fuzzy hash of the contents of the open file, starting at the beginning of the file. When finished, the file pointer is returned to its original position. If an error occurs, the file pointer's value is undefined. It is the callers's responsibility to append the filename to the result after computation. Returns an error when ssdeep could not be computed on the file.

func FuzzyFilename

func FuzzyFilename(filename string) (string, error)

FuzzyFilename computes the fuzzy hash of a file. FuzzyFilename will opens, reads, and hashes the contents of the file 'filename'. It is the caller's responsibility to append the filename to the result after computation. Returns an error when the file doesn't exist or ssdeep could not be computed on the file.

func FuzzyReader

func FuzzyReader(f Reader, fileSize int) (string, error)

FuzzyReader computes the fuzzy hash of a Reader interface with a given input size. It is the caller's responsibility to append the filename, if any, to result after computation. Returns an error when ssdeep could not be computed on the Reader.

Types

type Reader

type Reader interface {
	io.Seeker
	io.Reader
}

Reader is the minimum interface that ssdeep needs in order to calculate the fuzzy hash. Reader groups io.Seeker and io.Reader.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL