tlsh

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: Apache-2.0 Imports: 7 Imported by: 12

README

Workflow Go Report Card Go Reference

TLSH

Trend Micro Locality Sensitive Hash lib in Golang

Based on https://github.com/trendmicro/tlsh

See paper here: https://github.com/trendmicro/tlsh/blob/master/TLSH_CTC_final.pdf

TLSH is a fuzzy matching library. Given a byte stream with a minimum length of 256 bytes, TLSH generates a hash value which can be used for similarity comparisons. Similar objects will have similar hash values which allows for the detection of similar objects by comparing their hash values. Note that the byte stream should have a sufficient amount of complexity. For example, a byte stream of identical bytes will not generate a hash value.

The computed hash is 35 bytes long (output as 70 hexidecimal charactes). The first 3 bytes are used to capture the information about the file as a whole (length, ...), while the last 32 bytes are used to capture information about incremental parts of the file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffFilenames added in v0.2.0

func DiffFilenames(filenameA, filenameB string) (int, error)

DiffFilenames calculate distance between two files

Types

type FuzzyReader added in v0.2.0

type FuzzyReader interface {
	io.Reader
	io.ByteReader
}

FuzzyReader interface

type TLSH added in v0.3.0

type TLSH struct {
	// contains filtered or unexported fields
}

TLSH holds hash components

func HashBytes

func HashBytes(blob []byte) (*TLSH, error)

HashBytes calculates the TLSH for the input byte slice

func HashFilename added in v0.2.0

func HashFilename(filename string) (*TLSH, error)

HashFilename calculates the TLSH for the input file

func HashReader

func HashReader(r FuzzyReader) (*TLSH, error)

HashReader calculates the TLSH for the input reader

func New added in v0.2.0

func New() *TLSH

New represents type factory for Tlsh

func ParseStringToTlsh added in v0.3.0

func ParseStringToTlsh(hashString string) (*TLSH, error)

Parsing the hash of the string type

func (*TLSH) Binary added in v0.3.0

func (t *TLSH) Binary() []byte

Binary returns the binary representation of the hash

func (*TLSH) BlockSize added in v0.3.0

func (t *TLSH) BlockSize() int

func (*TLSH) Diff added in v0.3.0

func (t *TLSH) Diff(t2 *TLSH) int

Diff current hash with other hash

func (*TLSH) Reset added in v0.3.0

func (t *TLSH) Reset()

func (*TLSH) Size added in v0.3.0

func (t *TLSH) Size() int

func (*TLSH) String added in v0.3.0

func (t *TLSH) String() string

String returns the string representation of the hash`

func (*TLSH) Sum added in v0.3.0

func (t *TLSH) Sum(b []byte) []byte

func (*TLSH) Write added in v0.3.0

func (t *TLSH) Write(p []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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