Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] Lazarus - How to encode and decode a string to base64
Delphi, Lazarus, Free Pascal
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2860
Topic starter
October 19, 2015 5:42 AM
Sometimes, you'd want a string to be converted to base64 for what ever reason.
It's NOT a good method to encrypt data, but it can be handy when storing weird characters in an INI file in an (almost) unreadable format.
In Lazarus (for strings), this can be done very quick and easy.
Step 1 - Add "base64" to the Uses clause
Step 2 - Encode a string:
myEncodedString := EncodeStringBase64('some string');
Step 3 - Decode a string:
myDecodedString := DecodeStringBase64(myEncodedString);