tools

package
v0.1.38 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: BSD-2-Clause Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte = 1 << (iota * 10)
	KiByte
	MiByte
	GiByte
	TiByte
	PiByte
	EiByte
)

IEC Sizes. kibis of bits

View Source
const (
	IByte = 1
	KByte = IByte * 1000
	MByte = KByte * 1000
	GByte = MByte * 1000
	TByte = GByte * 1000
	PByte = TByte * 1000
	EByte = PByte * 1000
)

SI Sizes.

View Source
const IntelXSearchResultsFile = "intelx_search.json"

IntelXSearchResultsFile is the name of the JSON file the downloader ships inside the package alongside Info.csv, holding the raw records returned by the IntelX intelligent/search. The parser scans it for content like any data file, so intel that only appears in the search metadata is still captured.

Variables

This section is empty.

Functions

func Bytes

func Bytes(s uint64) string

Bytes produces a human readable representation of an SI size.

See also: ParseBytes.

Bytes(82854982) -> 83 MB

func CreateDir

func CreateDir(dir string) (string, error)

CreateDir creates a directory if it does not exist, returning the final normalized directory as a result.

func CreateDirFromFilename

func CreateDirFromFilename(destination string, s string) (string, error)

func CreateFileWithDir

func CreateFileWithDir(destination string) (string, error)

CreateFileWithDir creates a file, relative to a directory, returning the final normalized path as a result.

func ExtractCPF added in v0.1.20

func ExtractCPF(text string) (bool, string)

func FileExists

func FileExists(path string) bool

FileExists returns true if a path exists

func FileType

func FileType(path string) (string, error)

func Float64ToTime

func Float64ToTime(f float64) time.Time

Float64ToTime takes a float64 as number of seconds since unix epoch and returns time.Time

example field where this is used (expires field):

https://chromedevtools.github.io/devtools-protocol/tot/Network/#type-Cookie

func FormatInt64Comma

func FormatInt64Comma(n int64) string

func FormatIntComma

func FormatIntComma(n int) string

func GetHash

func GetHash(data []byte) string

func GetHashFromFile

func GetHashFromFile(file_path string) (string, error)

func GetHashFromValues added in v0.1.21

func GetHashFromValues(values ...interface{}) string

func GetMimeType

func GetMimeType(s string) (string, error)

func HammingDistance

func HammingDistance(hash1, hash2 []byte) (int, error)

HammingDistance calculates the number of differing bits between two byte slices.

func HumanateBytes

func HumanateBytes(s uint64, base float64, sizes []string) string

func IBytes

func IBytes(s uint64) string

IBytes produces a human readable representation of an IEC size.

See also: ParseBytes.

IBytes(82854982) -> 79 MiB

func IpsInCIDR

func IpsInCIDR(cidr string) ([]string, error)

IpsInCIDR returns a list of usable IP addresses in a given CIDR block excluding network and broadcast addresses for CIDRs larger than /31.

func LeftTrucate

func LeftTrucate(s string, max int) string

LeftTrucate a string if its more than max

func MoveFile

func MoveFile(sourcePath, destPath string) error

MoveFile moves a file from a to b

func ParseBytes

func ParseBytes(s string) (uint64, error)

ParseBytes parses a string representation of bytes into the number of bytes it represents.

See Also: Bytes, IBytes.

ParseBytes("42 MB") -> 42000000, nil ParseBytes("42 mib") -> 44040192, nil

func ParsePerceptionHash

func ParsePerceptionHash(hashStr string) ([]byte, error)

ParsePerceptionHash converts a perception hash string "p:<hex>" to a byte slice.

func ReadTextFile

func ReadTextFile(file_path string) (string, error)

func RemoveFolder

func RemoveFolder(path string) error

func SafeFileName

func SafeFileName(s string) string

SafeFileName takes a string and returns a string safe to use as a file name.

func SafeFileNameWithRnd added in v0.1.21

func SafeFileNameWithRnd(s string) string

SafeFileName takes a string and returns a string safe to use as a file name.

func SanitizeUTF8 added in v0.1.30

func SanitizeUTF8(s string) string

SanitizeUTF8 removes null bytes and invalid UTF-8 sequences from a string, ensuring it is safe for PostgreSQL UTF-8 encoding.

func ShuffleStr

func ShuffleStr(slice []string)

ShuffleStr shuffles a slice of strings

func SliceHasInt

func SliceHasInt(slice []int, item int) bool

SliceHasInt checks if a slice has an int

func SliceHasStr

func SliceHasStr(slice []string, item string) bool

SliceHasStr checks if a slice has a string

func TempFileName

func TempFileName(base_path, prefix, suffix string) string

func UniqueIntSlice

func UniqueIntSlice(slice []int) []int

UniqueIntSlice returns a slice of unique ints

func Unzip

func Unzip(src, dest string) error

Types

type HammingGroup

type HammingGroup struct {
	GroupID uint
	Hash    []byte
}

HammingGroup represents a hash -> group assignment used for inmemory hammingdistance calulations.

Jump to

Keyboard shortcuts

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