Skip to content

Allow custom hashing function in _make_hash #926

Open
@OneRaynyDay

Description

@OneRaynyDay

Hi again!

As we know, hash(x) in python yields different values across different interpreter sessions for security. It turns out that I am using attrs in all of my class definitions in a library and would like to bootstrap off of the programmatically generated hash function to essentially create a merkle tree. I would like to use hashlib.md5() or something similar and create a digest using all the attributes attrs can find in the class so that:

  1. the hash is consistent across runs.
  2. less importantly for me, but maybe more importantly for others, using a better hash allows for less collisions.

As always, please let me know if this is something attrs can/cannot support, and I will work with/around it accordingly. Thanks!

P.S. My workaround would be to define my own function to find all attributes using attr.asdict() and then creating a hash that way. Not terrible, but I figured it'd be worth asking for a "purer" solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions