taint

Crypto forensics for private use
git clone git://git.defalsify.org/taint.git
Log | Files | Refs | LICENSE

commit e533b649c7cffa9187b920cd3dc2fd1fc652f8fa
parent 707f4e75d3786f344a5f584bed13effea83c2c78
Author: nolash <dev@holbrook.no>
Date:   Fri, 16 Apr 2021 13:17:13 +0200

Add missing crypto module

Diffstat:
Mcrypto_account_cache/account.py | 13++-----------
Acrypto_account_cache/crypto.py | 18++++++++++++++++++
2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/crypto_account_cache/account.py b/crypto_account_cache/account.py @@ -1,20 +1,11 @@ # standard imports -import uuid import os -import hashlib # local imports from .tag import TagPool from .crypto import Salter -def sprinkle(data, salt): - h = hashlib.new('sha256') - h.update(data) - h.update(salt) - return h.digest() - - class Account(Salter): def __init__(self, account, label=None, tags=[], create_digest=True): @@ -24,7 +15,7 @@ class Account(Salter): self.account_src = None if create_digest: self.account_src = account - self.account = sprinkle(self.account_src, self.salt) + self.account = self.sprinkle(self.account_src) else: self.account = account self.tags = TagPool() @@ -45,7 +36,7 @@ class Account(Salter): def is_account(self, account): - return sprinkle(account, self.salt) == self.account + return self.sprinkle(account) == self.account def serialize(self): diff --git a/crypto_account_cache/crypto.py b/crypto_account_cache/crypto.py @@ -0,0 +1,18 @@ +# standard imports +import hashlib +import os + +class Salter: + + salt = os.urandom(32) + + def sprinkle(self, data): + h = hashlib.new('sha256') + if isinstance(data, list): + for d in data: + h.update(d) + else: + h.update(data) + h.update(self.salt) + return h.digest() +