SimpleBaseLib4Pascal
Simple to use Base Encoding Package for Delphi/FreePascal Compilers that provides at the moment support for encoding and decoding various bases such as Base16, Base32 (various variants), Base58 (various variants) and Base64 (various variants) and Base85 (various variants).
SimpleBaseLib4Pascal
Base encoding and decoding for Object Pascal
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.
Table of Contents
Features
- 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.
Available Encodings
- 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)
Getting Started
Prerequisites
- Delphi: 2010 and above
- FreePascal: 3.2.2 and above
Installation
Delphi
- 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.
FreePascal / Lazarus
- Open package:
SimpleBaseLib/src/Packages/FPC/SimpleBaseLib4PascalPackage.lpk
- Build/install package in Lazarus, or add
SimpleBaseLib/srcpaths to your FPC project.
Quick Examples
Base16 Encode/Decode
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;
Base64 URL Variant
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;
Running Tests
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
Tip Jar
If you find this library useful and would like to support its continued development, tips are greatly appreciated! 🙏
| Cryptocurrency | Wallet Address |
|---|---|
bc1quqhe342vw4ml909g334w9ygade64szqupqulmu |
|
0x53651185b7467c27facab542da5868bfebe2bb69 |
|
BPZHjY1eYCdQjLecumvrTJRi5TXj3Yz1vAWcmyEB9Miu |
License
This project is licensed under the MIT License.