(fwPreferences): add password management capabilities
What does this MR do?
This MR allow to specify a password, retrieve it from memory (it is stored in a scrambled form) and compare its sha256 hash to the one stored in preferences. This password is then used by SWriter and SReader to write and read encrypted data.
The code rely on fwPreferences helper and should be accessible from anywhere as static variable is used to hold the password in memory. This functions should be thread safe.
Three functions has been implemented:
/// Set the password to use in the application. If null or empty, erase it.
FWPREFERENCES_API void setPassword(const std::string& password);
/// Return the password used in the application.
FWPREFERENCES_API const std::string getPassword();
/// Check if the given password match the hash stored in the preferences
FWPREFERENCES_API bool checkPassword(const std::string& password);
/// Check if a password hash is stored in the preferences
FWPREFERENCES_API bool hasPasswordHash();
How to test it?
- launch
fwPreferencesTest
- Write an application that use .cpz format and set a password using
::fwPreferences::setPassword()
before saving and loading
Associated Issues/Merge Requests
-
Issues
- Fixes #481 (closed)
-
depends on https://git.ircad.fr/Sight/sight/issues/480
-
Merge requests