Merge pull request #97 from tuxxy/fingerprint

Make get_fingerprint an instance method
pull/100/merge
Justin Holmes 2017-11-04 17:18:14 -07:00 committed by GitHub
commit a10bdccc12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -12,11 +12,10 @@ class Key(Base):
key_data = Column(LargeBinary, unique=True)
def __init__(self, key_data):
self.fingerprint = Key.get_fingerprint(key_data[2:])
self.key_data = key_data
self.fingerprint = self.get_fingerprint()
@classmethod
def get_fingerprint(cls, key_data: bytes) -> bytes:
def get_fingerprint(self) -> bytes:
"""
Hashes the key with keccak_256 and returns the hexdigest as a String.
@ -24,4 +23,4 @@ class Key(Base):
:return: Fingerprint of key as a string
"""
return sha3.keccak_256(key_data).hexdigest().encode()
return sha3.keccak_256(self.key_data[2:]).hexdigest().encode()