8000 GitHub - guycipher/erk: Merkle tree of provided directory or file. Hashes files contents, outputs file contents hashes
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ erk Public

Merkle tree of provided directory or file. Hashes files contents, outputs file contents hashes

License

Notifications You must be signed in to change notification settings

guycipher/erk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

erk

erk provides functionality to compute the Merkle root and generate a detailed Merkle tree for files within a directory or a single file. It uses the xxHash algorithm(provided by github.com/cespare/xxhash/v2) for hashing file contents.

features

  • hash individual files or all files within a directory.
  • construct a Merkle tree from the hashed file data.
  • retrieve the Merkle root of the constructed tree.
  • print the Merkle tree in a human-readable format.

basic example

package main

import (
    "fmt"
    "log"
    "github.com/guycipher/erk"
)

func main() {
    // Create a new Erk instance
    e, err := erk.New("path/to/directory/or/file", true) // Set to false if input is a file
    if err != nil {
       log.Fatalf("Failed to create Erk instance: %v", err)
    }

    // Build the Merkle tree
    root := e.BuildTree()

    // Get the Merkle root
    merkleRoot := erk.GetMerkleRoot(root)
    fmt.Printf("Merkle Root: %x\n", merkleRoot)

    // Print the Merkle tree
    tree := erk.PrintTreeBytes(root, 0)
}

example tree output

2e8acb4bccf85227
    test_dir/f1.txt: 0a75a91375b27d44
    test_dir/f2.txt: 19a1d238fce6124f

About

Merkle tree of provided directory or file. Hashes files contents, outputs file contents hashes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0