Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.
/ merklehash Public archive

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

License

Notifications You must be signed in to change notification settings

chrisdoherty4/merklehash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
}