hynek / pem

PEM file parsing in Python.
https://pem.readthedocs.io/
MIT License
156 stars 37 forks source link

SHA1 digest to be a property of _Base class #30

Closed vladak closed 6 years ago

vladak commented 6 years ago

I use the pem library to compare 2 sets of certificate bundles. To quickly see what are the differences, it would be handy if the SHA1 digest was part of the _Base class so it does not have to be recomputed, i.e. so this is possible:

import pem
certs = pem.parse_file("cacert-2018-03-07.pem")
# print(hashlib.sha1(certs[0].as_bytes()).hexdigest())
print(certs[0].sha1) # avoids double digest computation
hynek commented 6 years ago

Hm computing them unconditionally seems unwise, maybe make it a cached property?

vladak commented 6 years ago

Yes, that's what I meant.

Dne so 16. 6. 2018 9:32 uživatel Hynek Schlawack notifications@github.com napsal:

Hm computing them unconditionally seems unwise, maybe make it a cached property?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hynek/pem/issues/30#issuecomment-397794240, or mute the thread https://github.com/notifications/unsubscribe-auth/ACzGDNHW2tJeTxVlod2UN5jFdz5IfTUJks5t9LSTgaJpZM4UbF4b .