PureBasic
PureBasic
Get Contents of File as Base64
See more Encryption Examples
Demonstrates how to read the contents of a file and convert to a base64 string.Chilkat PureBasic Downloads
IncludeFile "CkBinData.pb"
Procedure ChilkatExample()
success.i = 0
bd.i = CkBinData::ckCreate()
If bd.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkBinData::ckLoadFile(bd,"qa_data/jpg/starfish.jpg")
If success = 0
Debug "Failed to load file."
CkBinData::ckDispose(bd)
ProcedureReturn
EndIf
Debug CkBinData::ckGetEncoded(bd,"base64")
; If you want mult-line base64:
Debug "--"
Debug CkBinData::ckGetEncoded(bd,"base64_mime")
; If you want hex..
Debug "--"
Debug CkBinData::ckGetEncoded(bd,"hex")
; etc.
CkBinData::ckDispose(bd)
ProcedureReturn
EndProcedure