IP Converter
Pre requisites
Please make sure your desktop has sbt
installed beforehand.
For install sbt
, refer to: https://www.scala-sbt.org/1.0/docs/Installing-sbt-on-Mac.html
Running
- Running with
sbt
Run sbt in your project directory with no arguments: sbt
(it will start a sbt console).
And then run run "172.168.5.1"
to compile and start the project.
You can run exit
to exit the sbt console.
- Running with
./sbt
If your laptop does not have sbt
installed before, you can still run this project with
./sbt
to start a sbt consolerun "17 2.168 .5.1"
in sbt console
then you will get the answer you want.
Implementation Details
- Using Regex to validate the input IP
- Convert each decimal to 8-bit binary
- Contact the binary to 32-bit binary
- Convert 32-bit binary to decimal