-1

While executing this line of code:

DIGEST = sha256(json.dumps(CONFIG.__dict__, sort_keys=True)).hexdigest()

I got this error:

Unicode-objects must be encoded before hashing

Later I changed it to:

DIGEST = sha256(json.dumps(CONFIG.__dict__, encoding='utf-8', sort_keys=True)).hexdigest()

But doing that couldn't fix the error. Any solution for the same could be of great help.

Aran-Fey
  • 30,995
  • 8
  • 80
  • 121
  • 1
    Dupe: [How to correct TypeError: Unicode-objects must be encoded before hashing?](//stackoverflow.com/q/7585307) – Aran-Fey Aug 25 '18 at 07:21

1 Answers1

2
DIGEST = sha256(json.dumps(CONFIG.__dict__,sort_keys=True).encode('utf8')).hexdigest()

should work.

Travis
  • 89
  • 5