updated history encryption

First I merged master into your history and my corencryption, then merged the latter into the former with some changes.

Todo: if the user changes their password, we need to decrypt and reencrypt all their old data; this applies to everything, not just the db