Create a file of random bytes

Hi All,

I have the need to generate artificial files filled with random data. I don’t need crypto-level randomness, just the ability to quickly generate 4MB to 4GB worth of bytes per file.

I’ve created a couple of loops using Random, but it seems to take a very long time just to generate a few million bytes. On Linux or macOS, I would shell out and use something like:
dd if=/dev/urandom of=/sources/filename-4M.dat bs=4k count=512

Or similar. However, we don’t have that as an option for Windows, so I’m looking at options in Xojo that would work on all three Desktop platforms. MBS and Einhugur plugins are available and speed in generating a few hundred files is the major concern.

Ideas?

Thanks,
Tim

https://www.windows-commandline.com/how-to-create-large-dummy-file/

RandomBytesStringMBS function maybe?

Thanks but not really a help since I still have to generate the random content.

I knew I recalled something like that. Thanks.

did you try : https://documentation.xojo.com/api/cryptography/crypto.html#crypto-generaterandombytes

SQLite has a “randomblob” function. Should work on all platforms: randomblob(N)