Temp file that exists only in RAM?

前端 未结 5 408
梦毁少年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:37

    Using one of std::stringstream or fmemopen will get you file-like access to blocks of memory. If (for security) you want to avoid it being swapped out, use mlock which is probably easiest to use with fmemopen's buffer than std::stringstream. Combining mlock with std::stringstream would probably need to be done via a custom allocator (used as a template parameter).

提交回复
热议问题