安全地保留数据

发布于 2024-12-03 21:44:03 字数 151 浏览 8 评论 0原文

我们有一个在 Linux 上运行的 java 应用程序。 当应用程序崩溃并重新启动时,我们需要恢复(持久化)先前运行中存储的非常敏感的信息(全局静态变量)。 不允许使用数据库(不安全)。 同样重要的是,没有人可以在无法察觉的情况下更改此信息(例如覆盖文件等)。

提前致谢

we have a java application running on linux.
when the app crashes and restarted- we need to recover ( persist ) a very sensitive information that was stored in previous run ( global static var ).
no database allowed ( insecure ) .
also it's important that no-one can undetectably change this information ( e.g. override a file etc ).

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

時窥 2024-12-10 21:44:03

为了保护数据,您需要对其进行加密。在 CBC 或 CTR 模式下使用 AES-256 和 PKCS7 填充。不要不要将加密密钥存储在您的应用程序中。您可以存储 IV/nonce,因为它不需要安全。

为了确保数据不被更改,请使用带有 SHA-256 的 HMAC。您必须为 HMAC 使用与 AES 不同的密钥。

To secure the data you need to encrypt it. Use AES-256 in CBC or CTR mode with PKCS7 padding. Do not store the encryption key in your application. You can store the IV/nonce as it does not need to be secure.

To ensure that the data is not changed use HMAC, with SHA-256. You must use a different key for the HMAC than you used for AES.

天邊彩虹 2024-12-10 21:44:03

我建议使用 Jasypt
您可以实现 Externalized &加密对象流

BasicPasswordEncryptor encryptor = new BasicPasswordEncryptor();
String cipher = encryptor.encryptPassword(<<stream to encrypt as string>>);
...
if (encryptor.checkPassword(inputPassword, encryptedPassword)) {
  // correct!
} else {
  // bad login!
}

I'd suggest using Jasypt.
you can implement Externalizable & encrypt the object stream

BasicPasswordEncryptor encryptor = new BasicPasswordEncryptor();
String cipher = encryptor.encryptPassword(<<stream to encrypt as string>>);
...
if (encryptor.checkPassword(inputPassword, encryptedPassword)) {
  // correct!
} else {
  // bad login!
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文