销毁一个字符串 [英] Destroy a string

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

问题描述

我知道一个字符串是不可变的,但有任何技巧或任何其他方式

来销毁一个字符串


谢谢
www.quiznetonline.com

解决方案

好吧,只要它没有被实习,它应该(AFAIK)只需获得

可用时......你有特定的情况吗?


Marc


字符串是对象,所以,GC控制何时从

中删除对象堆。

" Mark C" < Ma ************* @ gmail.comwrote in message

news:11 ***************** *****@k21g2000cwa.googlegr oups.com ...


>我知道字符串是不可变的,但有任何技巧或任何其他方式

销毁字符串


谢谢
www.quiznetonline.com



不是,我认为你担心像密码之类的东西在页面文件等中结束

。 MS在V2中引入了SecureString,

然后在V3中撤销它(至少停止使用它),因为它只是没有

安全。你也可以尝试使用volatile char数组,我听说

这是一个选项,你可以(相当)确定它被覆盖了

你覆盖每个元素。我记得有关挥发性的问题,但我不会用它来赚钱,所以我不知道它们是什么。还有一些Win32 API调用

可以分配一些页面文件(在这里从内存工作,

基本上只是谷歌密码dotnet安全,那种事情)但

再次出现问题。

抱歉因为模糊不清,我前一段时间确实看过这个问题并且得出结论

结论没有没有防弹方式来保护

字符串,只需尝试将它们保存在内存中最短的时间

可能。

Mark C写道:


我知道字符串是不可变的,但有任何技巧或任何其他方式

来销毁字符串


谢谢
www.quiznetonline.com

I know a string is immutable, but is there any trick or any other way
to destroy a string

Thanks
www.quiznetonline.com

解决方案

Well, as long as it isn''t interned, it should (AFAIK) simply get
collected when available... do you have a specific situation in mind?

Marc


Strings are objects and so, the GC controls when objects are removed from
the heap.
"Mark C" <Ma*************@gmail.comwrote in message
news:11**********************@k21g2000cwa.googlegr oups.com...

>I know a string is immutable, but is there any trick or any other way
to destroy a string

Thanks
www.quiznetonline.com



Not really, I assume you''re worried about things like passwords ending
up in the page file and the like. MS introduced the SecureString in V2,
then revoked it in V3 (at least stopped using it) as it''s just not
secure. You can also try playing with volatile char arrays, I''ve heard
that''s an option in that you can be (fairly) sure it''s overwritten when
you overwrite each element. I recall issues with volatile, but I don''t
use it so don''t know what they are. There are also some Win32 API calls
which can allocate a bit of the page file (working from memory here,
basically just google password dotnet secure, that sort of thing) but
again that''s problematic.
Sorry for being nebulous, I did look at this a while ago and came to
the conclusion that no there''s no bulletproof way of protecting
strings, just try and hold them in memory for the shortest period
possible.
Mark C wrote:

I know a string is immutable, but is there any trick or any other way
to destroy a string

Thanks
www.quiznetonline.com


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

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