I am working on a secure password generator based on the following setup:

  1. choose a publicly know (text) file
  2. make some deliberate memorable changes to it
  3. use collected entropy for a secure password ???


  1. The text file can be anything provided it has a reasonable character count. For example: pick a book with $2^{20}$ characters ≈ 550 pages of human readable text

  2. Changing/inserting *) a character within this text from the base64 alphabet yields an estimated entropy of: 20 + 6 + 1 = 27bits correct ???

20bits = from the positions within the text

6bits = from the changed character (this is slightly less since the character that is to be changed can not be used from the base64 alphabet, but we can add an additional special character to base64 to overcome this)

1bit accounts for insertion or change of a character

*) any modifications to the text add different additional entropy: deleting passages, copying passages to different location, reversing passages, deleting pages etc,…

This yields more than twice the bits of diceware entropy (≈ 13bits)

3) Repeat step 2 to accumulate desired level of entropy in an other location of the file. Thus one could accumulate 135bits of entropy with only 5 modifications!?

4) Use this entropy to generate the password but how???

PROBLEM: I find using a simple sha512 on the modified text file and using the output as password might endanger the setup since:

The idea is to make the unmodified text file public and the adversary would then know $2^{20}$ - 5 = 1048571 characters (that’s almost 100%) that were not changed.

Is the below solution viable???

1) Transfer the text file into a $2^{10}$ characters by $2^{10}$ + x matrix (x is for padding, since the original length of the text file of $2^{20}$ characters might have increased if the user inserted some characters as part of his/her modification)

2) Hash with sha512: line by line to create an other $2^{9}$ bit by $2^{10}$ + x matrix

3) Hash the resulting matrix with sha512: column by column to create the final $2^{9}$ by $2^{9}$ matrix

4) finally xor the resulting matrix line by line to receive the $2^{9}$ bit password

Would this withstand the issue with the adversary knowing $2^{20}$ - 5 = 1048571 characters?


  • $\begingroup$ How exactly would you enter such a password? If you need to store or edit the text in some computing system, doesn't it turn into a usual password manager, in that you're relying on the software's security? $\endgroup$
    – ilkkachu
    Commented Oct 26, 2016 at 19:53
  • $\begingroup$ my setup is as follows: 1part: linux live iso, 2nd: luks with private data on it, without mounting luks no private data is revealed. Open leafpad load textfile, make 10 changes = 256bit strong pass,... $\endgroup$ Commented Oct 26, 2016 at 20:05
  • $\begingroup$ @ikkachu: If hypothetically one kept secret and stored the modified text (or a "diff"), then yes, it's equivalent to a password manager. But that doesn't sound like what the OP is proposing -- the user downloads the original text -- it's OK if an attacker sees every byte of that original file -- and the user has memorized a few changes to it. Then the user uses that modified file (or data derived from it) as a password, passphrase, or epic passpoem. $\endgroup$
    – David Cary
    Commented Oct 27, 2016 at 16:28
  • $\begingroup$ The idea is to get rid of the login-screen completely and define a protocol for user authentication. 1) User wants to login on his/her desktop machine 2) A text-editor is loaded instead a "linear" password prompt 3) The user deletes portions of the textfile, adds characters whatever and then hits the authenticate button 4) the modified textfile is hashed & salted and if it is correct voila you are in,... The idea is to accomplish a stronger password with less user input (no poems or meaningless special characters) $\endgroup$ Commented Oct 27, 2016 at 17:14
  • $\begingroup$ By a modified setup one could even achieve 92bits of entropy with just 2 modifications math.stackexchange.com/questions/1987170/… $\endgroup$ Commented Oct 27, 2016 at 17:21

1 Answer 1


I don't really see the problem with just hashing the modified text. Even when the original text is public information, you've already shown that introducing $n$ independent changes gives you $\approx27n$ bits of entropy. Hence given an output hash, finding the modified text should be as difficult as exhaustive search if the hash function has pre-image resistance (and collision resistance, to ensure that the hashes of your modified text “look random“ conditioned on your original text).

Anyway, your line-by-line construction looks to me equivalent to some other hash function which combines multiple SHA512 invocations, so I can't imagine it'd be any more secure. Why don't you simply make a diff (e.g. insert a at position 12381, change position 812931 to f) and hash the result?

  • $\begingroup$ +1. I agree that at first glance, the "line-by-line" algorithm, the "diff then hash" algorithm, and the "hash the modified file" all appear to give equivalent security, so I prefer the simplest one ("hash the modified file") to avoid unnecessary complexity. $\endgroup$
    – David Cary
    Commented Oct 27, 2016 at 16:19
  • $\begingroup$ @Mark & Cary thanx will do it that way $\endgroup$ Commented Oct 27, 2016 at 17:16

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