How to convert byte [] to positive BigInteger in Java?

I'm working with another team working in C The protocol we communicate with sends the IP address in byte [] format and two "Mask" values, namely byte [8] I want to use the IP address as BigInteger so that I can compare to see if the IP address is between 2 other IP addresses To ensure that the signature doesn't screw me up, I need a way to convert IP from byte [] (4 bytes for IPv4 or 16 bytes for IPv6) to a positive value in BigInteger Can someone guide me to refer to or suggest a way to complete this?

Solution

Simply use a constructor that accepts byte arrays and parameters to indicate whether it is positive or negative

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>