Coverage for portality/lib/anon.py: 86%

14 statements  

« prev     ^ index     » next       coverage.py v6.4.2, created at 2022-07-20 16:12 +0100

1# ~~Anonymisation:Feature~~ 

2import hashlib 

3from faker import Faker 

4 

5from portality.core import app 

6 

7fake = Faker() 

8 

9 

10def anon_email(email): 

11 if not email: 

12 return email 

13 

14 return hashlib.sha256(app.config['ANON_SALT'].encode('utf-8') + email.encode('utf-8')).hexdigest() + '@example.com' 

15 

16 

17def basic_hash(content): 

18 if not content: 

19 return content 

20 return hashlib.sha256(app.config['ANON_SALT'].encode('utf-8') + content.encode('utf-8')).hexdigest() 

21 

22 

23def anon_name(): 

24 return fake.name()