New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ipaddrhash

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipaddrhash

A predictable addressing scheme for statically assigned IPv6 and IPv4 addresses based on hostnames

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 26 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts