gpt4 book ai didi

javascript - 覆盖变量内容javascript

转载 作者:行者123 更新时间:2023-12-03 09:55:59 25 4
gpt4 key购买 nike

如果您有一个包含敏感数据的变量:

var secretPassword = 'myPa$sW0rd';

然后你覆盖它:

secretPassword = '0000000000';

JavaScript 引擎是否为新数据分配新内存?数据 myPa$sW0rd 是否仍然可能位于未分配的内存中?我的主要问题是:有没有办法保证覆盖数据? (即将其清零或安全删除数据)。我想知道循环遍历字符串中的字符并以这种方式重置它们是否可以做到这一点。

我认为您不可能在 JavaScript 引擎中没有错误的情况下访问数据。

最佳答案

Does a javascript engine allocate new memory for the new data?

是的

is the data myPa$sW0rd potentially somewhere in unallocated memory still?

是的,如果没有垃圾收集清理它

My main question is this: is there a way to guarantee that you overwrite the data? (ie zero it out or securely delete the data).

不是真的,除非你使用垃圾收集器。请参阅related post

I wonder if looping through the characters in the string and resetting them that way would do it.

没有

编辑:正如 doldt 所指出的,即使以前的数据仍在内存中的某个地方,也不存在真正的安全威胁。

关于javascript - 覆盖变量内容javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30735868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com