== Python Dev import hashlib with open(passwordfile, 'w', encoding='utf-8') as f: prefix = '%s:%s:' % (username, realm) value = (prefix + password).encode('utf-8') line = prefix + hashlib.md5(value).hexdigest() print(line, file=f)