Playing with /dev/urandom
I've just encountered some interesting matter to write about. Consider:
dd if=/dev/urandom of=/tmp/out bs=1024 count=10240
which gives us 10Mb of random binary junk. Lets try to compress it:
bzip2 -k --best /tmp/out
gzip --best /tmp/out;
zcat /tmp/out.gz > /tmp/out # to get original back
Now lets see whether such files worth compressing:
ls -la /tmp/out*
-rw-r--r-- 1 root root 10485760 Sep 7 16:34 /tmp/out
-rw-r--r-- 1 root root 10533366 Sep 7 16:32 /tmp/out.bz2
-rw-r--r-- 1 root root 10487382 Sep 7 16:32 /tmp/out.gz
As you may notice, compressed files are bigger than the original, probably due to added dictionary.
After all, we can see that /dev/uranom produces pretty random data :)
dd if=/dev/urandom of=/tmp/out bs=1024 count=10240
which gives us 10Mb of random binary junk. Lets try to compress it:
bzip2 -k --best /tmp/out
gzip --best /tmp/out;
zcat /tmp/out.gz > /tmp/out # to get original back
Now lets see whether such files worth compressing:
ls -la /tmp/out*
-rw-r--r-- 1 root root 10485760 Sep 7 16:34 /tmp/out
-rw-r--r-- 1 root root 10533366 Sep 7 16:32 /tmp/out.bz2
-rw-r--r-- 1 root root 10487382 Sep 7 16:32 /tmp/out.gz
As you may notice, compressed files are bigger than the original, probably due to added dictionary.
After all, we can see that /dev/uranom produces pretty random data :)
0 Comments:
Post a Comment
<< Home