From f7560b4311886054c35e67a0f082a4f22118b19f Mon Sep 17 00:00:00 2001 From: glaslos Date: Thu, 8 Jun 2017 15:33:26 +0200 Subject: [PATCH] HashBytes API added --- tlsh.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tlsh.go b/tlsh.go index 23bfc5d..4f89aeb 100644 --- a/tlsh.go +++ b/tlsh.go @@ -2,6 +2,7 @@ package tlsh import ( "bufio" + "bytes" "fmt" "io" "math" @@ -276,6 +277,12 @@ func HashReader(r fuzzyReader) (hash string, err error) { return hash, nil } +//HashBytes calculates the TLSH for the input byte slice +func HashBytes(blob []byte) (hash string, err error) { + r := bytes.NewReader(blob) + return HashReader(r) +} + //Hash calculates the TLSH for the input file func Hash(filename string) (hash string, err error) { f, err := os.Open(filename)