# A simple question about entropy and random data

Let's say I roll a 6-sided die 100 times and record the results into a 100 character string, for example:

``````//this is obviously an example (and very unlikely) outcome
"1234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234"
``````

I'm pretty sure that this 100 byte string has more than 256-bit entropy, making it next to impossible for anyone to ever find the same string. (I arrive at that entropy number because 6^99 < 2^256 < 6^100.)

Is this correct?

If so, I have further questions:

Does it follow from this that if I repeat the sequence I generated above 10 times,

``````"1234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234"
"1234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234"
"1234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234"
"1234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234"
"1234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234"
"1234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234"
"1234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234"
"1234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234"
"1234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234"
"1234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234561234"
``````

that I have now generated 1000 bytes of random data with 256-bit entropy?

Let's take this further. Can I take my initial string and repeat it 10,000,000,000 times and say that I have generated 1 terabyte of random data with 256-bit entropy?

I'm basically wondering whether I lose any entropy by repeating the same initial "seed" data.

Definitely not impossible, and you will not lose entropy by repeating seed data, but you will not gain any either.

By "they", I am just referring to a fictional person that is trying to figure out how your entropy is generated.

If they know that you are rolling a dice, they know each digit will be 1-6. If they know how many times you are rolling the dice, they know the length of the string. If they know the number is repeated 9 other times, they only need 100/1000 digits to calculate the entire string.

An attacker could have already deduced a number of possibilities by having this knowledge.

Technically, it is not completely random either.

Python example code:

``````# Generating dice rolls

import random

finalResult = ''

for i in range(0, 99):
finalResult += str(random.randint(1, 6))

finalResult = finalResult * 10

print finalResult
``````

Our result string is

``````"445656152532321321544533156515514562441512263431326526522641111345452422363416326462451246641163263445656152532321321544533156515514562441512263431326526522641111345452422363416326462451246641163263445656152532321321544533156515514562441512263431326526522641111345452422363416326462451246641163263445656152532321321544533156515514562441512263431326526522641111345452422363416326462451246641163263445656152532321321544533156515514562441512263431326526522641111345452422363416326462451246641163263445656152532321321544533156515514562441512263431326526522641111345452422363416326462451246641163263445656152532321321544533156515514562441512263431326526522641111345452422363416326462451246641163263445656152532321321544533156515514562441512263431326526522641111345452422363416326462451246641163263445656152532321321544533156515514562441512263431326526522641111345452422363416326462451246641163263445656152532321321544533156515514562441512263431326526522641111345452422363416326462451246641163263"
``````

The string yields 2.5806473 entropy bits.

If we were to repeat this string 100 times, the entropy bits yield 2.5806473, so you do not gain more entropy be repeating the same string. It has the exact same amount of entropy bits.

You could use a much better method to calculate those types of strings.

For example, let us use the following character set:

• (abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~`!@#\$%^&*()-_=+[{]}\|;:',<.>?/")

We could make each character correspond to a random number (0-9).

We will generate a random 100 character string 10 times, each result will be added onto the end of the other.

Python example code:

``````import random

finalResult = ''

for i in range(0, 9):
charSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~`!@#\$%^&*()-_=+[{]}\|;:',<.>?/"

charDict = {}

for char in charSet:
charDict[char] = random.randint(0, 9)

resultNum = ''

for c in range(0, 99):
resultNum += str(charDict[random.choice(charSet)])

finalResult += resultNum

print finalResult
``````

Our final result is

``````"989399239097499389189022059092089492027501842251063182295989039209500981690709174339560500718099187606453339255549850346696565025042504925549332139224650652008702541994436538038618150315533023690953265748197684554400738548471882056153703865878585568168785067956510245109630478032252017568653870833894188388554461614037175856595140494136416835954432291428646093513565418053453659690464509631548126684471012603870043241726762620992001266264567652958725540078190802887737716846137398760778230100671898578274611212550507493363271408738936020202251709524912326332192065460961427192491397953337291818408796519672933031867956012894824302218099239929701290857804033886980677310953734098050027009200344729070097168472819000050821260058120486772283080610287066869211061373297557455864016702744529267151023698266001761202821747262141933039130063624472814012939225414242779000144228077687272549297604021".
``````

The string yields 3.3067561 entropy bits.

Even if I were to repeat this string 100 times, the entropy bits would still be 3.3067561.

To generate 1 TB of random entropy, this would get the job done, however I don't suggest running the code, as it will crash your computer.

``````import random

finalResult = ''

for i in range(0, 999999999999):
charSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~`!@#\$%^&*()-_=+[{]}\|;:',<.>?/"

charDict = {}

for char in charSet:
charDict[char] = random.randint(0, 9)

resultNum = ''

for c in range(0, 99):
resultNum += str(charDict[random.choice(charSet)])

finalResult += resultNum

print finalResult
``````
• "The string yields 2.5806473 entropy bits." How do you arrive at this? Commented Aug 10, 2015 at 6:39
• Commented Aug 10, 2015 at 7:54
• Shannon entropy appears to be a measure of entropy per character. The calculator gives (approximately) the same answer even for truly random sequences of digits 1-6, of any length. Commented Aug 20, 2015 at 3:00
• "The string yields 3.3067561 entropy bits." No it does not. The calculator you used clearly states that number is "minimal number of bits per symbol" and goes on to further say that rounded up (to 4 bits) one would "need to use 3564 bits to encode your string optimally". Commented Aug 20, 2015 at 3:05
• @NPSF3000 Does the calculator's claim that "metric entropy" (Shannon entropy divided by message length) is a meaningful quantity hold any water? It seems suspicious to me, and the relevant text in the Wikipedia article doesn't seem to be referring to Shannon entropy. Commented Aug 20, 2015 at 3:17