Insanely Fast Base64 Module

I don’t really know how to introduce this module, so that’s why I used a block quote.

Overview:
This is a module that encodes and decodes strings into Base64. This is extremely useful if you want to store strings in data stores that have Unicode characters.

Analytics:

  • Encoding speed of 20,000,000 characters per second
  • Decoding speed of 15,000,000 character per second
  • Maximum input size of around 100 million
  • Reliable

Usage:

local B64 = require(script.Base64) --or wherever you are keeping the module
local encoded = B64.encode("Hello world!")
print(encoded) --Resault is '08l6rIZ68TZCsIhm8'
print(B64.decode(encoded)) --Resault is 'Hello world!'

Module:

Suggestions and feedback would make me slightly happy.

22 Likes

This is crazy powerful. Amazing job, although I personally don’t see a use for base64 I’m sure someone will have a great time with this!

“resault”, its result

nice work however, what use is there for this

1 Like

The main use for this module is encoding binary strings into safe ascii strings to be used with roblox apis (especially data stores, remote events, messaging service).

This is because roblox apis commonly pre-process the data through JsonEncode which will only accept characters < 128.

2 Likes

This looks good, but why would I encode my data in Roblox? One of the primary reasons for data encoding is safety, but exploiters cannot access data from data stores. And frankly, even if they could view other people’s data, you’re unlikely to save some personal information that is to be protected. I’m not sure how safe it is to use it in remote events either, I prefer performing server-side checks instead of trusting the client. Another reason why I might use it is to enhance the performance by storing strings with smaller sizes in data stores, but does it make the size smaller? It makes them longer, which means they should require more space. Is it somehow easier for the database to process them this way, and is it worth storing data this way, or there won’t be a significant difference? I thought of using something similar to the relational database model to store data, and that would be way more performant. Apologies for my scepticism, but I don’t understand why people encode data in Roblox. I’ll be glad if you explain.

The reason was stated in the thread though - storing data in a unicode-safe environment.

1 Like

This module isn’t intended to be any security / encryption standard, instead a binary-to-text encoding scheme. So yes, it will make your strings longer but if you need to store binary data in data stores / send it over remote events this would be a excellent solution. I feel like the Wikipedia article explains really well use cases Base64 - Wikipedia. Additionally, to answer your question why people may encode their data into Base64 on Roblox, is sometimes you just need to.

1 Like

This is gold and deserves more recognition, thanks, it’s just what I needed. No more working with characters that cause malformed strings due to zlib deflate compression, and en/decodes in an extremely fast manner which is helpful when working with a lot of data and (relatively) slow compression methods. You’re a life saver, thank you :relieved:

1 Like