bpm

simple-hash-c

v1.0.0 Native plugin

FNV-1a string hash — native plugin example, written in C.

@mamun MIT Published

Readme

simple-hash-c

FNV-1a 64-bit string hash. Native plugin example, written in C — one source file, one function, no third-party deps.

Install

bpm install simple-hash-c

bpm picks the right binary for your platform.

Use

import "simple-hash-c" as h;

print(h.version);          // 1.0.0
print(h.fnv1a("hello"));   // a430d84680aabd0b   (16-char hex)

API

  • fnv1a(s) — FNV-1a 64-bit hash of s, returned as a 16-char lowercase hex string
  • version — package version string

Build (for the maintainer)

The plugin uses zig as the toolchain — one small download, no Visual Studio, no Developer Command Prompt, no per-platform host. One command from any OS builds binaries for every target in bnl.json.

# 1. Install zig once
winget install zig.zig           # Windows
brew install zig                 # macOS
snap install zig --classic       # Linux

# 2. Build all 6 targets from any host
.\build.ps1                      # Windows
./build.sh                       # macOS / Linux

Output:

build/darwin-arm64/simple-hash-c.dylib
build/darwin-x64/simple-hash-c.dylib
build/linux-x64/simple-hash-c.so
build/linux-x86/simple-hash-c.so
build/windows-x64/simple-hash-c.dll
build/windows-x86/simple-hash-c.dll

The plugin only needs bnl/plugin.h (vendored in src/bnl/) — no bnl runtime link.

Publish (for the maintainer)

bpm publish

bpm reads the targets map in bnl.json, uploads one tarball per platform, and the registry resolves per-platform at install time.

MIT licensed.