-1

So I read this questionUrandom Alternative, but I am unable to make a comment there (without 50 rep) - therefore I open a separate question: If I use this command instead of dd and urandom, how do I set the size of the resulting randomfile.bin?

openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero > randomfile.bin
1
  • You can't comment on that question because it is locked, because it isn't an on-topic question for this site. Neither is this question.
    – womble
    Aug 16, 2015 at 5:07

1 Answer 1

3

The problem is that you are reading from /dev/zero that will generate infinity zeros, a way to limit it is using head command to control the size of the output, and pipe that instead of passing it as the input file. So a way to generate a 65535 file is the following:

head -c 65535 /dev/zero | openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt  > randomfile.bin
1
  • The thing is, I want to create a 100gb file, which is afterwards used as LUKS container. Thanks a lot, your solution worked out fine! Aug 15, 2015 at 18:38

Not the answer you're looking for? Browse other questions tagged .