Fully web-based converter between various encoding formats (utf8, hex, base64) and hashes.
Available at: https://convert.dubniczky.com
Many converter tools exist on the internet, but most focus on one specific type of conversion, such as text to base64 and reverse. I wanted to create a tool that:
- Works exclusively from the browser and requires only static file hosting
- The converted data never leaves the local machine, so it can be used with sensitive information
- It allows encoding from and decoding to many formats with universal compatibility between each
- It has an easy and intuitive user interface
- It can perform more complex conversions, format shifting, hashing, and counting.
The biggest challenge by far was making sure that the universal conversion works between all formats without having to create specific converters between all format combinations. One function for each pair would result in
I made the decision to convert every input format into bytes and convert every output format from bytes. This reduces the compexity to UInt8Array objects that work quite similarly, but lack the built-in compatibility.
This seemed like the most manageable solution, so I created two converters for each type. One that converts it to UInt8Array or converts it from UInt8Array. Each conversion happens by converting the input to this custom bytes object, then converting those bytes to any of the output formats. With this, we can perform modifications on the data both with the input and the output functions. This means that it's possible to, for example, paste a base64 encoded string, convert into bytes, which are then hashed and finally output with hex encoding. All this happens in one go.
- app.js contains a list of definitions on what formats can be converted from and to
- converters.js contains the converters for each custom format
The test cases are in tests.js. After loading the web page, open the developer console and run:
runTests()If there are any errors in the test cases, the details will appear in the console.