fingerprint

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package fingerprint generates the WFP (Winnowing FingerPrint) of a file using the original WFP1 algorithm (30-byte grams, 64-hash window). GenerateFingerprint reads a file, computes a whole-file CRC64 hash, and derives per-line winnowing minutiae, emitting the "file=..." WFP text the scan uploads.

Index

Constants

View Source
const (
	GRAM_WFP1   = 30
	WINDOW_WFP1 = 64
)

Variables

This section is empty.

Functions

func CombineFingerprints added in v0.6.0

func CombineFingerprints(fps []*FileFingerprint) string

CombineFingerprints joins fingerprints into the single WFP stream a scan uploads, with a blank line between files as the format requires.

The builder is pre-sized because a naive `result += ...` is O(n²) — each += copies the whole accumulated string — and that dominated wall-clock time on large scans: ~38s to assemble a 16 MB WFP from ~8900 files.

Types

type FileFingerprint added in v0.5.0

type FileFingerprint struct {
	Path        string // path of the fingerprinted file, relative to the scan root
	Hash        string // whole-file hash
	Size        int    // file size in bytes
	Fingerprint string // the WFP text itself, "file=..." and its minutiae
}

FileFingerprint is one file's fingerprint: what the scan uploads about it, and what every stage between hashing and upload passes around.

It lives here, beside the function that produces it, because it is the vocabulary the fingerprinting packages speak to each other in — the worker pool and the scan service both name it. Kept out of reach, it would leave those packages with signatures no caller could write down.

func GenerateFingerprint

func GenerateFingerprint(filePath string, root string) (*FileFingerprint, error)

GenerateFingerprint generates the WFP fingerprint of a file. The file is read from filePath; root, when non-empty, makes the WFP "file=" label relative to it (so the scan result reports paths relative to the scanned folder, not absolute local paths).

Jump to

Keyboard shortcuts

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