Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fast QB64 base64 encoder & decoder
#1
RETIRED! See this post.

This is a Base64 encode, decode, and resource loader library based on MODP_B64, a C-based super-fast Base64 encoder and decoder library.

The library has 4 functions:
Code: (Select All)
''' @brief Converts a normal STRING or binary data to a base64 STRING.
''' @param src The normal STRING or binary data to be converted.
''' @return The base64 STRING.
FUNCTION Base64_Encode$ (src AS STRING)

''' @brief Converts a base64 STRING to a normal STRING or binary data.
''' @param src The base64 STRING to be converted.
''' @return The normal STRING or binary data.
FUNCTION Base64_Decode$ (src AS STRING)

''' @brief Loads a binary file encoded with Bin2Data (CONST).
''' @param src The base64 STRING containing the encoded data.
''' @param ogSize The original size of the data.
''' @param isComp Whether the data is compressed.
''' @return The normal STRING or binary data.
FUNCTION Base64_LoadResourceString$ (src AS STRING, ogSize AS _UNSIGNED LONG, isComp AS _BYTE)

''' @brief Loads a binary file encoded with Bin2Data (DATA).
''' Usage:
'''  1. Encode the binary file with Bin2Data.
'''  2. Include the file or its contents.
'''  3. Load the file like so:
'''      Restore label_generated_by_bin2data
'''      Dim buffer As String
'''      buffer = Base64_LoadResourceData
''' @return The normal STRING or binary data.
FUNCTION Base64_LoadResourceData$

It's much faster than my earlier QB64-only implementation which you can find here: Something Tricky (qb64phoenix.com).

Here are some numbers from my Ryzen 5600X box.

[Image: Screenshot-2024-12-21-092426.png]

I threw in Win32 API-based Base64 encoder & decoder wrappers for the benchmark. However, the library is cross-platform.

The numbers in the image are with C++ optimizations turned on. However, even with optimizations turned off MODP_B64 runs circles around Win32 and my earlier implementation.

The Bin2Data tool lives here: https://qb64phoenix.com/forum/showthread.php?tid=2228


Attached Files
.zip   libbase64.zip (Size: 86.78 KB / Downloads: 176)
Reply


Messages In This Thread
Fast QB64 base64 encoder & decoder - by a740g - 11-18-2023, 07:26 AM
RE: Fast QB64 base64 encoder & decoder - by Dav - 11-18-2023, 04:35 PM
RE: Fast QB64 base64 encoder & decoder - by a740g - 12-21-2024, 04:43 AM
RE: Fast QB64 base64 encoder & decoder - by a740g - 02-23-2025, 10:30 PM
RE: Fast QB64 base64 encoder & decoder - by Pete - 02-24-2025, 09:00 PM
RE: Fast QB64 base64 encoder & decoder - by a740g - 02-25-2025, 01:36 AM
RE: Fast QB64 base64 encoder & decoder - by Pete - 02-24-2025, 11:11 PM
RE: Fast QB64 base64 encoder & decoder - by a740g - 02-25-2025, 05:06 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)