临时文件只存在于RAM中

临时文件只存在于RAM中

本文介绍了临时文件只存在于RAM中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用OTP方法写一个encrpytion。根据安全理论,我需要纯文本文档只存储在内存中,从来不会写入物理驱动器。 tmpnam命令似乎是我需要的,但从我可以看到它保存在磁盘上的文件而不是RAM。

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 written to a physical drive. The tmpnam command appears to be what I need, but from what I can see it saves the file on the disk and not the RAM.

使用C ++有任何独立)方法,允许文件只存在于RAM?如果可能,我想避免使用RAM磁盘方法。

Using C++ is there any (platform independent) method that allows a file to exist only in RAM? I would like to avoid using a RAM disk method if possible.

感谢

编辑:
谢谢,它只是一个学习的东西对我来说,我是新的加密,只是通过不同的方法,我实际上没有计划使用它们(特别是OTP,由于原来的文件大小,因为pad )。

Thanks, its more just a learning thing for me, I'm new to encryption and just working through different methods, I don't actually plan on using many of them (esspecially OTP due to doubling the original file size because of the "pad").

如果我完全诚实,我是一个Linux用户,所以弃置Windows不会太糟糕,我正在研究使用RAM磁盘

If I'm totally honest, I'm a Linux user so ditching Windows wouldn't be too bad, I'm looking into using RAM disks for now as FUSE seems a bit overkill for a "learning" thing.

推荐答案

简单的答案是:没有,没有平台独立的方式。

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.

在Windows上,您可以使用 VirtualLock() 强制内存留在RAM中。

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.

在POSIX系统(例如BSD,Linux)上,您可以使用 CryptProtectMemory() mlock()可锁定RAM中的内存。

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

这篇关于临时文件只存在于RAM中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 02:06