So I have a program that has the user enter a passphrase. I only hold the passphrase for a few seconds in a char[]
before overwriting it but I was wondering if there was a way in Java to prevent the OS from swapping this bit to disk/virtual memory/any more permanent storage than RAM? Research on the topic seems to say no, there is not a way but no where has given me a straight answer yet. I'm also not sure if I can achieve this by using mlock() somehow or by keeping a reference to the value active until I no longer need it.
Thanks!