SwiftGUI_Encryption 0.0.3__tar.gz → 0.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SwiftGUI_Encryption
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: Useful encryption-features for SwiftGUI-applications based on PyCryptoDome
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "SwiftGUI_Encryption"
3
- version = "0.0.3"
3
+ version = "0.0.4"
4
4
  packages = [
5
5
  { include = "SwiftGUI_Encryption", from = "src" }
6
6
  ]
@@ -107,8 +107,10 @@ class PasswordJSONDictFile(EncryptedJSONDictFile):
107
107
  **kwargs
108
108
  )
109
109
 
110
- def _regenerate_key(self):
111
- self._salt = random_key(SALT_LEN)
110
+ def _regenerate_key(self, new_salt = True):
111
+ if new_salt:
112
+ self._salt = random_key(SALT_LEN)
113
+
112
114
  self._filekey = adv.argon2_key_derivation(self._password.encode(), self._salt)
113
115
 
114
116
  def change_key(self, new_key: bytes):
@@ -151,6 +153,11 @@ class PasswordJSONDictFile(EncryptedJSONDictFile):
151
153
  ) -> dict:
152
154
  raw = path.read_bytes()
153
155
 
156
+ salt = raw[:SALT_LEN]
157
+ if salt != self._salt:
158
+ self._salt = salt
159
+ self._regenerate_key(new_salt=False)
160
+
154
161
  raw = decrypt_full(raw[SALT_LEN:], self._filekey).decode()
155
162
  return json.loads(raw)
156
163