Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Latest commit

 

History

History
40 lines (27 loc) · 1.05 KB

File metadata and controls

40 lines (27 loc) · 1.05 KB

Gitlab pipeline status

merklehash

A go implementation of a merkle tree for hashing arbitrary sized directories.

Caution should be exercised when hashing directories with large files or large quantities of files as it could take some time. Should a platform support recursive symlinks one must be careful to ensure they do not exist within the directory being hashed as it'll result in an infinite loop.

Install

go get "github.com/chrisdoherty4/merklehash"
go install "github.com/chrisdoherty4/merklehash"

merklehash <directory>

API

The merkletree package exposes a single function, New(). The function accepts a context.Context that can be cancelled by the caller as desired.

Example

package main

import "github.com/chrisdoherty4/merklehash/merkletree"

func main() {
  path := "/directory/to/hash"
  hash, _ := merkletree.New(context.Background(), path, sha256.New)

  fmt.Printf("%x\n", hash)
}