Creating unique junk data with pwgen

… when you need to generate many files with unique payloads … enter pwgen and some shell scripting.

Though I use 1Password to manage access to accounts, I seldom use its password creation mechanism and instead generate and (sometimes) augment the result of pwgen for that purpose.

I’ve also found pwgen useful for generating many junk files with different payloads such that, say, they have different content signatures as the result of various hashing methods. The following snippet shows the generation of these files:

for j in {1..5}; do mkdir $j && for i in {1..100}; do pwgen -n $(expr $j \* $i \* 1000) 1 > $j/$i.txt; done & done

…where the command uses pwgen to create a file at 1K, 2K, … to 5K then multiplies that argument by 1-100 to generate a set of files with random contents. This, of course, is not the most efficient way of achieving this, as you could simply have a prefixed-seed value for each size of file you need and concatenate a random value or counter to obtain different hash results.

Also, I really should upgrade to sf-pwgen.

comments powered by Disqus