beaugunderson / ip-address

💻 a library for parsing and manipulating IPv4 and IPv6 addresses in JavaScript
http://ip-address.js.org/
MIT License
525 stars 71 forks source link

ipAddress.fromBigInteger() not returning the correct address #98

Closed tejpartapg closed 4 years ago

tejpartapg commented 4 years ago

Hello @beaugunderson ,

Please see attached screenshot of the test code on npm Runkit. I am trying to convert an IPv4 address to big integer through the method provided in documentation and then converting the big integer value back to IPv4 address. The first octet is not correct but rest of the address is converted correctly. Could you please confirm if this issue is not present in the actual code? I would like to make use of this library in my project. Also I noticed from the documentation that there is no method to convert to an IPv4 from binary. Would you happen to know a workaround on how to go about accomplishing that? IP-Address-npm

Thank you

beaugunderson commented 4 years ago

@tejpartapg sorry for the delayed reply--there is no need to index into the returned bigInt object; you need to pass in the whole thing.

e.g., this will have the desired effect:

ipAddress.fromBigInteger(bigInt);