Programmers - what's the best way to do this?

S

ss821z

The task is to make duplicates of a file but with different MD5sums by
adding 4 bytes of random text (possibly using /dev/urandom) and a
further 1-100KBytes of empty text (ASCII code 00).

All I can think off is:
head -n 4 /dev/urandom
for 4 bytes but I don't know how to correctly append that to the binary
file and add further empty text.

Any help much appreciated.
 
M

mst

The task is to make duplicates of a file but with different MD5sums by
adding 4 bytes of random text (possibly using /dev/urandom) and a
further 1-100KBytes of empty text (ASCII code 00).

Why?
 
D

Dave Kelly

The task is to make duplicates of a file but with different MD5sums by
adding 4 bytes of random text (possibly using /dev/urandom) and a
further 1-100KBytes of empty text (ASCII code 00).

All I can think off is:
head -n 4 /dev/urandom
for 4 bytes but I don't know how to correctly append that to the binary
file and add further empty text.

Any help much appreciated.

I think 'mst' question if very good.... Why?
Is the a home work assignment?

Dave
 
U

Unruh

That could be a very very long addition. -n 4 means write 4 lines. A line
is something terminated by '\n' so it depends on how far in the first 4 \n
are.

man head.


man bash
man null
 
S

Stan Milam

The task is to make duplicates of a file but with different MD5sums by
adding 4 bytes of random text (possibly using /dev/urandom) and a
further 1-100KBytes of empty text (ASCII code 00).

All I can think off is:
head -n 4 /dev/urandom
for 4 bytes but I don't know how to correctly append that to the binary
file and add further empty text.

Any help much appreciated.

What is /dev/urandom? Does it exist on my ReallyCool (tm) operating system?

Perhaps use fopen("/dev/random", "r+b") then use fread() and read 4
bytes? Hmmm, this sounds suspiciously like homework. Better not say
any more.
 
S

snnn

The task is to make duplicates of a file but with different MD5sums by
adding 4 bytes of random text (possibly using /dev/urandom) and a
further 1-100KBytes of empty text (ASCII code 00).

All I can think off is:
head -n 4 /dev/urandom

Maybe you should use
head -c 4 /dev/urandom
instead
 
N

nog

The task is to make duplicates of a file but with different MD5sums by
adding 4 bytes of random text (possibly using /dev/urandom) and a
further 1-100KBytes of empty text (ASCII code 00).

All I can think off is:
head -n 4 /dev/urandom
for 4 bytes but I don't know how to correctly append that to the binary
file and add further empty text.

Any help much appreciated.

Student?
 
S

Simon Biber

Unruh said:
That could be a very very long addition. -n 4 means write 4 lines. A line
is something terminated by '\n' so it depends on how far in the first 4 \n
are.

head -n 4 /dev/urandom will output, on average, 1024 bytes, because the
newline is one character out of 256 possible, and you want 4 of them.
The theoretical minimum is 4, and there is no theoretical maximum. The
number of bytes it outputs will follow some statistical distribution.
I'm not sure which one.

Experimentally, after 65536 runs, the average was 1024.6239, the minimum
was 35, the maximum was 4584, and the standard deviation was 511.5605.

Excel analysis here
http://members.optushome.com.au/sbiber/stuff/head-urandom.zip

Simon.
 
R

ray

The task is to make duplicates of a file but with different MD5sums by
adding 4 bytes of random text (possibly using /dev/urandom) and a
further 1-100KBytes of empty text (ASCII code 00).

All I can think off is:
head -n 4 /dev/urandom
for 4 bytes but I don't know how to correctly append that to the binary
file and add further empty text.

Any help much appreciated.

'cat'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top