updated history encryption

First I merged master into your history and my corencryption, then merged the latter into the former with some changes. The merging master into your history is the source of most of these commits.

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