Skip to content

drummonds/godocs-hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

godocs-hash

Compute document hashes compatible with godocs.

External tools can use this library to pre-check whether a document already exists before uploading.

Algorithm

MD5 of the raw file bytes, formatted as 32-character lowercase hex.

Install

go get github.com/drummonds/godocs-hash

Usage

import godocshash "github.com/drummonds/godocs-hash"

hash, err := godocshash.HashFile("invoice.pdf")
// Check: GET https://your-godocs/api/document/lookup?hash=<hash>
// 200 → already exists, skip upload
// 404 → upload via POST /api/document/upload

Three functions are provided:

  • HashFile(path) — hash a file by path
  • HashReader(r) — hash from any io.Reader
  • HashBytes(data) — hash in-memory bytes

Shell equivalent

md5sum invoice.pdf | cut -d' ' -f1

Python equivalent

import hashlib
hashlib.md5(open("invoice.pdf", "rb").read()).hexdigest()

Links

Documentation https://h3-godocs-hash.statichost.page/
Source (Codeberg) https://codeberg.org/hum3/godocs-hash
Mirror (GitHub) https://github.com/drummonds/godocs-hash
Docs repo https://codeberg.org/hum3/godocs-hash-docs

About

Encapsulated hash library for godocs and tooling

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages