Skip to content

Convert IP address to its binary/decimal/hexadecimal/octal representation and vise versa

License

Notifications You must be signed in to change notification settings

gorangorun/ip-to-base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ip-to-base - Convert IP address to its binary/decimal/hexadecimal/octal representation and vise versa


Installation

# npm ..
$ npm install ip-to-base 
# yarn ..
$ yarn add ip-to-base

Usage

This is a practical example of how to use.

import { IpToBase, BaseToIp } from 'ip-to-base'

// convert ip address to binary
const result = new IpToBase('127.0.0.1', 2).convert()

console.log(result)
// 01111111000000000000000000000001

// convert binary to ip address
const result = new IpToBase('01111111000000000000000000000001', 2).convert()

console.log(result)
// 127.0.0.1

Online converter