Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
484 views
in Technique[技术] by (71.8m points)

hex - Creating hexadecimal MAC address

I’m a student and not a pro in programming. Right now, I’m working on my college project. However, I want to develop something different, I expect making something different might help me to get a full time job easily.

I’m developing a file transfer tool to transfer file to the computers connect on a LAN. I am going to use Vue.js in the front-end and node.js in the back-end. I planned to save the IP address of each computer system in my database and the name of a person to which that computer system belongs. For example, for Mike’s PC, the IP address 192.168.10.1 will be saved in the database and for Sam’s PC, IP address 192.168.10.2 would will be saved in the database. There are 256 ports in a network so we can save 256 IPs in one network. If Mike wants to send a file to Sam then Mike will just have to select Sam’s name from the front-end, attach a file and send. My Node.js server will get Sam’s IP address and send file on the address with socket.io.

I just found out that the LAN address of each system may change if the sitting arrangement is changed. So, I decided to convert the unique numbers ID into hexadecimal numbers, when required, it should convert hexadecimal to decimal numbers like them and then store that into the database. Whenever a user sends a file to another user, the file should be sent to this hexadecimal MAC address. The reason I chose hexadecimal instead of binary for sending is because the actual MAC address of a computer system is also in the form of hexadecimal.

What I already know?

  • Database connectivity with node.js, vue.js and mongodb
  • Networking with node js
  • Sending a file with socket.io

What I do not know?

  • MAC addresses
  • Hexadecimal numbers and conversion

I will be really grateful if you share your thoughts.

question from:https://stackoverflow.com/questions/66064435/creating-hexadecimal-mac-address

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since you are using Vue.js in the front-end, here is the code for hexadecimal to decimal conversion: Installing Bignumber.js npm package would be great to handle big numbers:

var x = new BigNumber(this.text_value, 16)
    var dectobin = x.toString(10);
    this.ans = dectobin;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...