add encryption support

This commit is contained in:
Ari Lazier 2016-02-26 11:08:59 -08:00
parent 4b8f83bd70
commit 00d2c2a74a
2 changed files with 8 additions and 0 deletions

View File

@ -72,6 +72,9 @@ Realm::Realm(Config config)
m_group = m_read_only_group.get();
}
else {
if (m_config.encryption_key.data() && m_config.encryption_key.size() != 64) {
throw InvalidEncryptionKeyException();
}
m_history = realm::make_client_history(m_config.path, m_config.encryption_key.data());
SharedGroup::DurabilityLevel durability = m_config.in_memory ? SharedGroup::durability_MemOnly :
SharedGroup::durability_Full;

View File

@ -199,6 +199,11 @@ namespace realm {
public:
UnitializedRealmException(std::string message) : std::runtime_error(message) {}
};
class InvalidEncryptionKeyException : public std::runtime_error {
public:
InvalidEncryptionKeyException() : std::runtime_error("Encryption key must be 64 bytes.") {}
};
}
#endif /* defined(REALM_REALM_HPP) */