-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
user1252280
  • 119
  • 4
  • 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 '15 at 05:07

1 Answers1

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
Pablo Martinez
  • 2,326
  • 16
  • 13
  • 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! – user1252280 Aug 15 '15 at 18:38