I'm sure secure strings have been brought up before. Always willing to learn more about WB CLR:
[EDIT]... I visited this topic in 2019, but forgot that thread.
method = 1 ;change to a different value for testing
string="GameofThrones"
ObjectClrOption("useany","System")
oSS = ObjectClrNew("System.Security.SecureString")
oSS.Clear()
For i = 1 To Strlen(string)
objChar = ObjectClrNew("System.Char")
ObjChar.Parse(StrSub(string,i,1))
oSS.AppendChar(System.Char:ObjChar)
Next
n = oSS.Length
Message("Secure String Length",n:@LF:oSS)
if method == 1
;this will work in Powershell, but fails - so I"m missing something
oPS = ObjectClrOption("useany","System.Runtime.InteropServices")
oPS1 = ObjectClrNew("System.Runtime.InteropServices.Marshal")
data = oPS1.SecureStringToBSTR(oSS)
Message("data pointer",data)
pw = oPS1.PtrToStringAuto(data) ;fails here
else
;this will work but not display text
oPS = ObjectClrOption("useany","System.Management.Automation")
oPS1 = ObjectClrNew("System.Management.Automation.PSCredential","test",oSS)
pw = oPS1.GetNetworkCredential.Password
endif
Message("Secure String Text",pw)
oSS=0
oPS=0
oSS=0
Exit