Coverage for portality/lib/anon.py: 93%
14 statements
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-22 15:59 +0100
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-22 15:59 +0100
1# ~~Anonymisation:Feature~~
2import hashlib
3from faker import Faker
5from portality.core import app
7fake = Faker()
10def anon_email(email):
11 if not email:
12 return email
14 return hashlib.sha256(app.config['ANON_SALT'].encode('utf-8') + email.encode('utf-8')).hexdigest() + '@example.com'
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()
23def anon_name():
24 return fake.name()