How does one store password hashes securely in memory, when creating accounts?(创建帐户时,如何将密码哈希安全地存储在内存中?)
问题描述
我们基于 Web 的应用程序将用户帐户绑定到具有在帐户创建期间指定的密码的用户.在 Java 的情况下,如何安全地处理密码,然后将其哈希保存在数据库中.
Our web-based applications has user accounts tied down to users with the passwords specified during account creation. In the case of Java, how does one process the password securely, before persisting its hash in the database.
更具体地说,如何确保保存密码的字符串在足够短的时间间隔内被垃圾回收?
To be more specific, how does one ensure that the string holding the password is garbage collected within a sufficiently short interval of time ?
推荐答案
如果有可能(在 web 应用程序中可能很难),最好将密码存储在字符数组中而不是存储在字符串中.如果您完成了密码的存储,您可以使用 Array.fill() 并通过丢弃它使引用可用于垃圾收集器:
If you have the possibility (may be difficult in web applications), it would be better to store passwords in character arrays than to store them in strings. If you finished storing the password you can overwrite it in memory by using Array.fill() and make the reference available for the garbage collector by discarding it:
Arrays.fill(password, ' ');
password = null;
我刚刚注意到,取消密码有点偏执,但如果它让你放心,你可以这样做:)
I just noticed that nulling the password would be a bit paranoid but you can do if it reassures you :)
这篇关于创建帐户时,如何将密码哈希安全地存储在内存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:创建帐户时,如何将密码哈希安全地存储在内存中?


- Eclipse 插件更新错误日志在哪里? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01