C ++麦克风输入作为随机种子 [英] C++ Microphone Input As A Random Seed
问题描述
我目前正在使用某种加密技术(在这种情况下为RSA公钥),为了生成随机密钥,我需要一个随机输入.我认为麦克风将是相对不可复制的数据的良好来源.是否有任何方法可以用麦克风播种方式从麦克风中读取原始数据?有没有更好的方法来获取纯随机种子,如果可以的话,我该怎么办?
I am currently playing around with some cryptography (RSA Public Key, in this case) and in order to generate a random key I need a random input. I figured the microphone would be a good source for relatively unreplicatable data. Is there any way to read the raw data out of a microphone in a way that can be used as to seed srand? Is there a better way to get a purely random seed and if so how would I do it?
我正在带有内置麦克风的笔记本电脑上运行Windows 8,并且正在使用g ++编译器.
I am running Windows 8 on a laptop with a built in mic and I am using the g++ compiler.
推荐答案
不要不要尝试自己从硬件中获取种子.操作系统比您更了解如何获得质量随机性.
Do not try to get seed from hardware yourself. The OS knows a lot more than you about how to get quality randomness.
在Linux上,正确的方法是读取/dev/urandom
(不是/dev/random
;它实际上毫无价值)
On Linux, the correct way is to read /dev/urandom
(not /dev/random
; it is actually worthless)
在Windows上,Google指示您应使用 CryptGenRandom
函数.
On Windows, Google indicates that you should use the CryptGenRandom
function.
这篇关于C ++麦克风输入作为随机种子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!