1 from abc import ABCMeta
2 from abc import abstractmethod
4 from pygost.utils import hexenc
7 # This function is taken from six package as is
8 def add_metaclass(metaclass):
9 """Class decorator for creating a class with a metaclass."""
11 orig_vars = cls.__dict__.copy()
12 slots = orig_vars.get("__slots__")
14 if isinstance(slots, str):
16 for slots_var in slots:
17 orig_vars.pop(slots_var)
18 orig_vars.pop("__dict__", None)
19 orig_vars.pop("__weakref__", None)
20 return metaclass(cls.__name__, cls.__bases__, orig_vars)
24 @add_metaclass(ABCMeta)
28 def digest_size(self):
29 """The size of the digest produced by the hashing objects.
34 """Return a separate copy of this hashing object.
38 def update(self, data):
39 """Hash data into the current state of the hashing object.
44 """Return the hash value as a string containing 8-bit data.
48 """Return the hash value as a string containing hexadecimal digits.
50 return hexenc(self.digest())