private static unsafe SecureString CreateSecureString(string value) { if (string.IsNullOrEmpty(value)) { return new SecureString(); } fixed (char* mychars = value.ToCharArray()) { return new SecureString(mychars, value.Length); } }