How can I securely wipe a confidential data in memory in java with guarantee it will not be 'optimized'?

后端 未结 4 705
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 12:29
String secret=\"foo\";
WhatILookFor.securelyWipe(secret);

And I need to know that it will not be removed by java optimizer.

4条回答
  •  不思量自难忘°
    2020-12-06 13:31

    Store the data off-heap using the "Unsafe" methods. You can then zero over it when done and be certain that it won't be pushed around the heap by the JVM.

    Here is a good post on Unsafe:

    http://highlyscalable.wordpress.com/2012/02/02/direct-memory-access-in-java/

提交回复
热议问题