将字符串转换为SecureString的 [英] Convert String to SecureString

查看:923
本文介绍了将字符串转换为SecureString的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何字符串转换为SecureString的?

How to convert String to SecureString?

推荐答案

您没有。整个之所以使用SecureString的目的是避免创建一个字符串对象(被加载到内存中,并保持明文那里直到垃圾收集)。但是,您可以通过附加它们的字符添加到SecureString的

You don't. The whole reason for using the SecureString object is to avoid creating a string object (which is loaded into memory and kept there in plaintext until garbage collection). However, you can add characters to a SecureString by appending them.

var s = new SecureString();
s.AppendChar('d');
s.AppendChar('u');
s.AppendChar('m');
s.AppendChar('b');
s.AppendChar('p');
s.AppendChar('a');
s.AppendChar('s');
s.AppendChar('s');
s.AppendChar('w');
s.AppendChar('d');

这篇关于将字符串转换为SecureString的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆