11-18-2023, 07:26 AM
(This post was last modified: 12-21-2024, 06:27 AM by a740g.
Edit Reason: Fixed some typo
)
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:
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.
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
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.
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