Temp file that exists only in RAM?

前端 未结 5 410
梦毁少年i
梦毁少年i 2021-01-19 03:24

I\'m trying to write an encrpytion using the OTP method. In keeping with the security theories I need the plain text documents to be stored only in memory and never ever wri

5条回答
  •  不知归路
    2021-01-19 03:43

    The simple answer is: no, there is no platform independent way. Even keeping the data only in memory, it will still risk being swapped out to disk by the virtual memory manager.

    On Windows, you can use VirtualLock() to force the memory to stay in RAM. You can also use CryptProtectMemory() to prevent other processes from reading it.

    On POSIX systems (e.g. BSD, Linux) you can use mlock() to lock memory in RAM.

提交回复
热议问题