Rizwan Akram
Rizwan Akram

Reputation: 1

How to create true random number generator using atmosphere noise(recorded mp3, wave etc) on python?

I need to convert audio atmosphere file to bit to use it as a secret keys in stream cipher cryptography.

I don't know the logic of converting audio file to bits.

Upvotes: 0

Views: 254

Answers (1)

rossum
rossum

Reputation: 15693

Generating cryptographically secure random number is not a trivial task. It is possible to do it from an audio file, but it needs some work.

First, you need some random input. A common method is to disconnect the microphone input and record the random thermal noise generated in the electronics of the sound card.

Then you need to estimate the amount of entropy (randomness) in the resulting file.

Then take a chunk of the file with more than 256 bits of entropy, preferably a lot more, say 2K bits of entropy, and pass it through a good cryptographic hash function, say SHA-256.

That will give you 256 bits of cryptographically secure randomness. Process the next chunk of the file in the same way for more random bits as necessary.

Do not use a pre-recorded sound file, as @NemoYuan2008 says. That will allow an attacker to run exactly the same process on exactly the same file. You also have the standard OTP problem of how to pass the keystream to the intended recipient, and to no-one else.

Upvotes: 0

Related Questions