Fix bug in CryptoEngine
Properly write and read database is old and new format