How to get secret key based on multiple passwords? e.d we have cipher encrypted by combination of passwords "qwe" and "asd", and our purpose to decode the cipher using any of passwords above separately?


  • $\begingroup$ I actually answered a question with the same solution as this recently, I will see if I can find it $\endgroup$ Aug 17, 2016 at 0:33
  • $\begingroup$ maybe it was not the same, but quite similar and adaptable to this problem: crypto.stackexchange.com/questions/33030/… $\endgroup$ Aug 17, 2016 at 0:46

2 Answers 2


You can do this by generating a (random) encryption key for the data and then encrypting that key separately with each of the passwords, using some password-based encryption.

To decrypt the user can use any of the passwords to decrypt the encryption key, then use that to decrypt the actual data. If the password-based encryption used is authenticated encryption, the decrypter can decrypt each of the encrypted keys and use the one where the authentication checks out.


It is basically a two level encryption:

  • passphrase (possibly passed throught a KDF) is used for master key encryption

  • master key is used for data encryption

  • multiple key-slot, once for every passphrase are possible

  • there is only one master key

  • there are as many encrypted master keys as the number of passphrases

You can find a valid example in LUKS (Full Disk Encryption solution) https://gitlab.com/cryptsetup/cryptsetup


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.