I am pretty new in python, and I have a problem I don't know how to solve.
For example, I have this struct with members such as administrator, berit, etc:
DEFAULT_DATA = {
'administrator': {
'name': 'Admin',
'pw': 'secret',
'is_author': False,
'is_admin': True
}
'berit': {
'name': 'berit',
'pw': 'apa',
'is_author': False,
'is_admin': False
}
This data is then accessible via a method this method:
def DefaultData():
"""Provides default data for Gruyere."""
return copy.deepcopy(DEFAULT_DATA)
I want to do a md5 hash on the passwords so they are not in plaintext, but I have no idea how to access the fields such as 'pw' and reassign a new value in python.
Here's a guess as to what it might be:
stored_data = data.DefaultData()
for member in stored_data:
for field in member:
if field=='pw':
'pw' = md5.new(salt+pw).hexdigest() // how do you access the value?