How would you see this working? Just providing a way to encode credentials passed to the function, which one could use in a call, or something more involved?
Basic authentication with base64 is not that complicated {or secure ::) } a few lines of CLR code with ObjectClrNew('System.Text.Encoding') and ObjectClrNew('System.Convert') and I think there is a base64 extender and some older UDF's in the Tech DB. But if it wouldn't be that difficult to package in your Extender it would help with WinHTTP API requests...
user = 'winbatch'
pw = '$ecretF!le'
pair = user:":":pw
request = Createobject("WinHttp.WinHttpRequest.5.1")
request.Open("GET", [myURL], @False )
request.SetRequestHeader("Authorization", "Basic ":base64String(pair))
; etc...etc
where base64String() is your function. I know I will use your Extender for the Json and SQlite functionality with web requests so a function like that would be an extra benefit. But others might not see it that way... so maybe put it up for a vote.
I apologize. Not sure how I did that...
b64Encode() and b64Decode().
No worries: looks good compared to CLR
AddExtender("c:\scripts\dom\wbOmnibus.dll") ;change path
user = 'winbatch'
pw = '$ecretF!le'
pair = user:":":pw
omni = b64Encode(pair)
oEncode = ObjectClrNew('System.Text.Encoding')
oCvt = ObjectClrNew('System.Convert')
oAsc = oEncode.ASCII
bUser = oCvt.ToBase64String(oAsc.GetBytes(user))
bPW = oCvt.ToBase64String(oAsc.GetBytes(pw))
bPair = oCvt.ToBase64String(oAsc.GetBytes(pair))
message("Base64",BUser:@LF:BPW:@LF:bPair:@LF:omni)