SimpleBaseLib4Pascal is a base encoding/decoding library for Object Pascal with support for multiple base families, non-allocating APIs, and stream-based APIs across Delphi and FreePascal.
- Base encoding/decoding implementations for common and extended base families.
- Multiple alphabet variants for several bases (for example Base32, Base58, Base64, Base85).
- Non-allocating
TryEncode/TryDecodeAPIs for performance-sensitive paths. - Stream-based encode/decode support for large inputs.
- Compatible with both Delphi and FreePascal toolchains.
- Base2
- Base8
- Base10
- Base16
- Base32 (RFC 4648, Crockford, Extended Hex, and more)
- Base36
- Base45
- Base58 (Bitcoin, Ripple, Flickr, Monero variants)
- Base62
- Base64 (Default, URL-style variants)
- Base85 (Ascii85, Z85)
- Delphi: 2010 and above
- FreePascal: 3.2.2 and above
- Open package:
SimpleBaseLib/src/Packages/Delphi/SimpleBaseLib4PascalPackage.dpk
- Build and install the package in the IDE.
- Add
SimpleBaseLib/srcsubfolders to your project search path if needed.
- Open package:
SimpleBaseLib/src/Packages/FPC/SimpleBaseLib4PascalPackage.lpk
- Build/install package in Lazarus, or add
SimpleBaseLib/srcpaths to your FPC project.
uses
SysUtils, SbpBase16;
var
LBytes: TBytes;
LText: String;
begin
LBytes := TBytes.Create($DE, $AD, $BE, $EF);
LText := TBase16.UpperCase.Encode(LBytes); // DEADBEEF
LBytes := TBase16.UpperCase.Decode(LText);
end;uses
SysUtils, SbpBase64;
var
LData: TBytes;
LEncoded: String;
begin
LData := TBytes.Create($FB, $FF, $EF);
LEncoded := TBase64.Url.Encode(LData);
LData := TBase64.Url.Decode(LEncoded);
end;Tests are provided for both Delphi and FreePascal.
- Delphi: open and run
SimpleBaseLib.Tests/Delphi.Tests/SimpleBaseLib.Tests.dpr
- FreePascal/Lazarus: open and run
SimpleBaseLib.Tests/FreePascal.Tests/SimpleBaseLib.Tests.lpi
If you find this library useful and would like to support its continued development, tips are greatly appreciated! 🙏
This project is licensed under the MIT License.