File tree Expand file tree Collapse file tree 1 file changed +1
-5
lines changed Expand file tree Collapse file tree 1 file changed +1
-5
lines changed Original file line number Diff line number Diff line change 1
1
from typing import Any , Dict
2
2
3
3
from appconf import AppConf
4
- from cryptography .hazmat .backends import default_backend
5
4
from cryptography .hazmat .primitives import hashes
6
5
from cryptography .hazmat .primitives .kdf import pbkdf2
7
6
from django .conf import settings
8
7
from django .utils .encoding import force_bytes
9
8
10
9
11
10
class CryptographyConf (AppConf ):
12
- BACKEND = default_backend ()
13
11
DIGEST = hashes .SHA256 ()
14
12
KEY = None
15
13
SALT = "django-cryptography"
@@ -22,16 +20,14 @@ def configure_salt(self, value: Any) -> bytes:
22
20
return force_bytes (value )
23
21
24
22
def configure (self ) -> Dict [str , Any ]:
25
- backend = self .configured_data ["BACKEND" ]
26
- digest = self .configured_data ["DIGEST" ]
23
+ digest = self .configured_data ["DIGEST" ]()
27
24
salt = self .configured_data ["SALT" ]
28
25
# Key Derivation Function
29
26
kdf = pbkdf2 .PBKDF2HMAC (
30
27
algorithm = digest ,
31
28
length = digest .digest_size ,
32
29
salt = salt ,
33
30
iterations = 30000 ,
34
- backend = backend ,
35
31
)
36
32
self .configured_data ["KEY" ] = kdf .derive (
37
33
force_bytes (self .configured_data ["KEY" ] or settings .SECRET_KEY )
You can’t perform that action at this time.
0 commit comments