(DataFlex) Base64 Encode/Decode a String
DataFlex example to base-64 encode and decode a string.
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoBd
String s
Boolean iSuccess
String sStrBase64
2 Handle hoBd2
String sDecoded
Get Create (RefClass(cComChilkatBinData)) To hoBd
If (Not(IsComObjectCreated(hoBd))) Begin
Send CreateComObject of hoBd
End
Move "A friend called me up the other day and talked about investing in a dot-com that sells lobsters. Internet lobsters. Where will this end? --Donald Trump" To s
Get ComAppendString Of hoBd s "utf-8" To iSuccess
Get ComGetEncoded Of hoBd "base64" To sStrBase64
Showln sStrBase64
// To decode:
Get Create (RefClass(cComChilkatBinData)) To hoBd2
If (Not(IsComObjectCreated(hoBd2))) Begin
Send CreateComObject of hoBd2
End
Get ComAppendEncoded Of hoBd2 sStrBase64 "base64" To iSuccess
Get ComGetString Of hoBd2 "utf-8" To sDecoded
Showln sDecoded
End_Procedure
|