network-address-utilities
v1.0.1
Published
A repository that generates IPv4, IPv6, MAC address, and converting IPv4 address to decimal value, compressed IPv6, and expanded IPv6 address.
Downloads
4
Readme
network-address-utilities
A repository that generates IPv4, IPv6, MAC address, and converting IPv4 address to decimal value, compressed IPv6, and expanded IPv6 address.
This repository can be used for generating sample test data while filling a database.
Disclaimer
The code provided in this package is intended for educational and informational purposes only. The author(s) of this package shall not be held responsible for any loss, damage, or liability arising from the use, misuse, or incorrect application of the code.
It is the user's responsibility to ensure that the code is used in a lawful and responsible manner. The author(s) do not condone or encourage the use of this code for any unlawful or unethical purposes.
By using this package, you agree to indemnify and hold the author(s) harmless from and against any and all claims, damages, and expenses, including attorney's fees, arising out of or resulting from your use of the code.
The author(s) reserve the right to modify, update, or remove the code at any time without prior notice. The user is responsible for keeping up with any changes or updates to the code.
Use of this package is at your own risk. The author(s) make no warranties, express or implied, and hereby disclaim all implied warranties, including any warranty of merchantability and warranty of fitness for a particular purpose.
Sample case
const { Distributions } = require("network-address-utilities");
const { generateIPv4Address, generateIPv6Address, generateMACAddress } = require("network-address-utilities");
const { ipv4ToDecimal, decimalToIpv4, ipv4ToIpv6Compressed, ipv6CompressedToIpv4, ipv4ToIpv6Expanded, ipv6ExpandedToIpv4 } = require("network-address-utilities");
console.log(generateIPv4Address()); // Generates an IPv4 address with uniform distribution
console.log(generateIPv6Address()); // Generates an IPv6 address with uniform distribution
console.log(generateMACAddress()); // Generates a MAC address with uniform distribution
console.log(generateIPv4Address(Distributions.GAUSSIAN)); // Generates an IPv4 address with gaussian distribution
console.log(generateIPv6Address(Distributions.EXPONENTIAL)); // Generates an IPv6 address with exponential distribution
console.log(generateMACAddress(Distributions.POISSON)); // Generates a MAC address with poisson distribution
console.log(ipv4ToDecimal(generateIPv4Address())); // Generates an IPv4 address with uniform distribution then convert it to decimal
console.log(ipv4ToIpv6Compressed(generateIPv4Address())); // Generates an IPv4 address with uniform distribution then convert it to compressed IPv6 form
console.log(ipv4ToIpv6Expanded(generateIPv4Address())); // Generates an IPv4 address with uniform distribution then convert it to expanded IPv6 form
console.log(decimalToIpv4(ipv4ToDecimal(generateIPv4Address()))); // Revert
console.log(ipv6CompressedToIpv4(ipv4ToIpv6Compressed(generateIPv4Address()))); // Revert
console.log(ipv6ExpandedToIpv4(ipv4ToIpv6Expanded(generateIPv4Address()))); // Revert