You can do it with the NetworkCredential type:
(new System.Net.NetworkCredential(“”, “myString”)).SecurePassword