Is there any way to create binary translator?

I’m a computer science student and working on my final year project which i will have to submit before March’22. Due to covid-19, i have learned everything from freecodecamp youtube channel and a few other youtube videos and articles. I’m building a file sharing app which will work on LAN, and not the internet required just all the system should be on the same network. I’m using Vue.js in the front-end and node.js in the back-end to share all the LAN IP addresses in the database and process the data. To share this file via LAN IP address I will use Socketio library.

When on paper documents, this project seems interesting and complicated but honestly, I have not done anything extra-ordinary. I found all the code online and most of my friends have also done the same.

Why I’m looking to develop a binary translator?

  • For the tasks like database connectivity, two-way data binding, using AXIOS to send and receive requests, using socket.emit & seocket.send methods, saving values in database, it is really easy for me.

For that reason, I’m planning to convert all the inputs into binary numbers and then save to the database. This is the first step, the second step is to change the IP address from dynamically according in the database with the help of routing tables. Because LAN addresses keep on changing while a MAC is unique address of a system just like username on twitter. But for now, i want to create a binary translator that can convert binary into all the other numbering systems.

After searching online, I found the following code:

bin to hex:
var binn = m.toString(16).toUpperCase();

bin to oct:

var bintooct = parseInt(this.xxx, 2).toString(8)

bin to dec:

var cc = new BigNumber(parseInt(this.number1, 2))

Working on bin to text and text to bin

Hi @rohaansharma,
Is your project on github? Sounds interesting.

A few thoughts…

  • Using SocketIO, do you still need any type of IP handling? I would think socketio emits either for all sockets or targetted ones without any need to worry about IPs (or MACs if IPs are dynamic). Sidenote: I remember to have run a DHCP server on my laptop (as opposed to the router), and make IPs static. Obviously this can also be done straight from the router.

  • The convertion with parseInt and bignumber seems ok, but if you plan to convert the whole file to a “binary string” ( if i get it properly), I don’t think converting to string and then to binary will work.
    Also, remember that not all databases store large objects. I believe MongoDB has 16MB maximum size per document.
    If you plan to access the binary representation of the file, maybe this post helps.. Also there is a special mongoDB to handle large file sizes.

Yes, socketio does not require an IP address but I’m saving user’s ip address in the database and send the file on that address. For example, user ‘A’ currently has currently an local address 192.161.16.1. So, this address is not a permanent address. Once this address dis-connects and then connects, the router will assign this system a new IP address. For that reason, I will have to refer the routing table to send file on a perticular IP address. Once file is deliver, my server will automatically delete this file.

I have also found the binary to text code from this website https://binarytotext.net. However their code is not perfect as well. This tool works for just 11 characters while I have made changes in the code and my code works for 16 character input.

code:

      var bintext, textresult = '', binlength
var aaa = input_number;
bintext = aaa.replace(/[^01]/g, '')
binlength = bintext.length - (bintext.length % 8)
for (var z = 0; z < binlength; z = z + 8) {
  textresult += String.fromCharCode(parseInt(bintext.substr(z, 8), 2))
  var answer = textresult

I’m now working on the dynamically fetching information from the routing table where I will have the details of the MAC address and the assigned IP addresses to that MAC address. I have ordered a CIsco router which most companies use now a days. Will start the practices once router arrives.