Let's say we generate a sentence in a way like for example this: Fix an initial seed. Attach '1' at the end of the seed and compute sha256 of such a string. This hash is our first number. Now attach 2 at the end of the seed(instead of 1 like in the previous step) and compute sha256 to get our 2nd number. And so on.

Will this sequence behave randomly? Would it be possible to extract any information about the inital seed if enough numbers of the generated sequence are known? Does anything in this matter change if we decrease the size of the generated numbers by, for example, truncating the hash to a couple of the initial bytes or taking the hash modulo a very small number?

  • 1
    $\begingroup$ This sounds extremely similar to crypto.stackexchange.com/questions/33867/… $\endgroup$ Commented Mar 21, 2016 at 23:33
  • $\begingroup$ Not only is it difficult to compute the initial seed, I believe that this is actually a secure stream cipher. $\endgroup$
    – Demi
    Commented Mar 22, 2016 at 2:30

1 Answer 1


This is basically how KDF1 and KDF2 work: use a secret, add a (constant sized) label + possible other values such as a salt and then use this as input for a hash value.

Another way to look at it is to view the seed + number as a new number and then reduce the problem to the problem that Richie Frame pointed at.


  1. yes it will behave randomly
  2. no, no information about the seed can be retrieved
  3. truncation of hashes is a well known method, and will not leak any more information
  • $\begingroup$ It would be rather strange if removing data would generate more information. There must be some kind of law against that. $\endgroup$
    – Maarten Bodewes
    Commented Mar 21, 2016 at 23:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.