hb_base64Ex – URL-safe Base64 encoder/decoder for mod_harbour
Hi everyone,
Here’s a practical solution to a common issue in mod_harbour web applications:
When sending Base64-encoded data (like an id) from the backend to the frontend, the ‘+’ character often gets lost when the frontend sends it back—especially via URLs or form fields. This causes decoding errors or mismatches.
To solve this, I created hb_base64Ex, a Harbour module that provides:
Example usage:
Project structure:
GitHub link: https://github.com/WenSheng-tw/harbour-base64-extend
Hope this helps others working with mod_harbour and frontend integration.
Feedback and suggestions are welcome!
Best regards,
WenSheng
Hi everyone,
Here’s a practical solution to a common issue in mod_harbour web applications:
When sending Base64-encoded data (like an id) from the backend to the frontend, the ‘+’ character often gets lost when the frontend sends it back—especially via URLs or form fields. This causes decoding errors or mismatches.
To solve this, I created hb_base64Ex, a Harbour module that provides:
- URL-safe Base64 encoding ([tt]+[/tt] → [tt]-[/tt], [tt]/[/tt] → [tt]_[/tt])
- Optional removal of padding ([tt]=[/tt]) for JWT-style output
- Auto-detection of standard vs URL-safe formats during decoding
- UTF-8 compatibility via [tt]hb_cdpSelect("UTF8")[/tt]
- Error handling for illegal characters
Example usage:
hb_cdpSelect( "UTF8" ) // Ensure UTF-8 encoding
cEncoded := hb_base64EncodeEx( "123+456", .T. ) // URL-safe, no padding
// → "MTIzLTQ1Ng"
cDecoded := hb_base64DecodeEx( cEncoded )
// → "123+456"hb_base64Ex/
├── base64cEx.c // Encoder module
├── base64dEx.c // Decoder module
├── test.prg // Sample test program
├── test.hbp // Build configuration
└── README.md // DocumentationHope this helps others working with mod_harbour and frontend integration.
Feedback and suggestions are welcome!
Best regards,
WenSheng
line ID: ssbbstw
WeChat ID: ssbbstw
WeChat ID: ssbbstw