/// <summary> /// Decrypt password into hash; it will take one minute /// </summary> /// <param name="password">Password to use for decryption</param> /// <param name="isStillValid">Function to indicate if calculated password is still valid and should be used</param> public void DecryptKey(string password, Func <bool> isStillValid = null) { var keyPassword = EncryptionService.GetKeyInBytes(password); if (isStillValid == null || isStillValid()) { KeyPassword = keyPassword; } }
/// <summary> /// Encrypt all data in the dictionary /// </summary> /// <param name="password">Password to use for encryption</param> /// <param name="callback">Callback to run after initialization (if needed) and encryption is finished</param> public void EncryptAll(string password, Action callback = null) { if (EncryptionService.IterationsPerMinute == null) { if (EncryptionService.IsInitializationRunning) { EncryptionService.InitializationCallback = () => { var keyPassword = EncryptionService.GetKeyInBytes(password); EncryptAll(keyPassword); callback?.Invoke(); }; } } else { var keyPassword = EncryptionService.GetKeyInBytes(password); EncryptAll(keyPassword); callback?.Invoke(); } }
/// <summary> /// Encrypt all that that were not yet encrypted /// </summary> /// <param name="password">Password to use for encryption</param> public void EncryptNotEncrypted(string password) { var keyPasssword = EncryptionService.GetKeyInBytes(password); EncryptNotEncrypted(keyPasssword); }