The "Authorization" request header for basic authentication is a string that starts with "Basic ". Then follows a BASE64 codes string of "username:password".
For Base64 encoding you may use the CryptBinaryToStringW function of Windows API:
Function Boolean CryptBinaryToString ( &
blob pbBinary, &
ulong cbBinary, &
ulong dwFlags, &
Ref string pszString, &
Ref ulong pcchString) Library "Crypt32.dll" Alias For "CryptBinaryToStringW"
blob lblob_text
string ls_b64
unsignedlong lul_buflen
CONSTANT ulong CRYPT_STRING_BASE64 = 1
CONSTANT ulong CRYPT_STRING_NOCRLF = 1073741824
IF IsNull (as_text) THEN return as_text
lblob_text = Blob (as_text, EncodingUTF8!)
ls_b64 = Space (2 + 1.5 * (Len (lblob_text) + 2))
lul_buflen = Len (ls_b64)
IF Not CryptBinaryToString (lblob_text, Len (lblob_text), CRYPT_STRING_BASE64 + CRYPT_STRING_NOCRLF, ls_b64, lul_buflen) THEN
// error handling
End If
return ls_b64
FYI ... The next Appeon PB release PB2017R3 coming out next month - BASE64, Cryptography, etc methods will be built-in.
Regards ... Chris