ipaddrhash
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

ipaddrhash

Implements a predictable addressing scheme for statically assigned IPv6 and IPv4 addresses based on hostnames. Supports node and modern browsers.

The algorithm used to derive an ip is simple:

ip = prefix + (sha256(seed) & hostmask)

Installation

npm install ipaddrhash --save-dev

Usage

ESM:

import { ipaddrHash, ipaddrPrefixSize } from "ipaddrhash";

CommonJS:

const { ipaddrHash, ipaddrPrefixSize } = require("ipaddrhash");

Example:

const prefix = "2001:db8::/64";
const fqdn = "example.com";
const size = ipaddrPrefixSize(prefix);
if (size !== undefined && fqdn.length > 0) {
  ipaddrHash(size, prefix, fqdn).then((result) => {
    // should output:
    // 2001:db8::13d2:1255:86ce:1947
    console.log(result);
  });
}

License

GNU General Public License v3.0 or later

Readme

Keywords

none

Package Sidebar

Install

npm i ipaddrhash

Weekly Downloads

4

Version

1.1.0

License

GPL-3.0-or-later

Unpacked Size

46.4 kB

Total Files

8

Last publish

Collaborators

  • znerol