Example #1
0
 def test_config_not_equals_values(self):
     """
     Hasher Equality: False when configs have same keys, different values
     """
     salt = token_bytes(32)
     hasher_a = muteacle.ScryptHasher(salt, meta=self.meta, keylen=32)
     hasher_b = muteacle.ScryptHasher(salt, meta=self.meta, keylen=64)
     self.assertNotEqual(hasher_a, hasher_b)
Example #2
0
 def test_config_not_equals_keys(self):
     """
     Hasher Equality: False when configurations have different keys
     """
     salt = token_bytes(32)
     hasher_a = muteacle.ScryptHasher(salt, meta=self.meta, keylen=64)
     hasher_b = muteacle.ScryptHasher(salt, keylen=64)
     self.assertNotEqual(hasher_a, hasher_b)
Example #3
0
 def test_config_not_equals_salts(self):
     """
     Hasher Equality: False when salts differ
     """
     salt_a = token_bytes(32)
     salt_b = token_bytes(32)
     hasher_a = muteacle.ScryptHasher(salt_a)
     hasher_b = muteacle.ScryptHasher(salt_b)
     self.assertNotEqual(hasher_a, hasher_b)
Example #4
0
 def test_config_equals_custom(self):
     """
     Hasher Equality: True when class and configuration are identical
     This test involves Hashers set up to have identical configurations
     """
     salt = token_bytes(32)
     hasher_a = muteacle.ScryptHasher(salt, meta=self.meta, keylen=64)
     hasher_b = muteacle.ScryptHasher(salt, meta=self.meta, keylen=64)
     self.assertEqual(hasher_a, hasher_b)
Example #5
0
 def test_config_equals_default(self):
     """
     Hasher Equality: True when class and configuration are identical
     This test involves Hashers left in their default configuration
     """
     salt = token_bytes(32)
     hasher_a = muteacle.ScryptHasher(salt)
     hasher_b = muteacle.ScryptHasher(salt)
     self.assertEqual(hasher_a, hasher_b)
Example #6
0
 def test_config_not_equals_classes(self):
     """
     Hasher Equality: False when classes differ
     """
     salt = token_bytes(32)
     hasher_a = muteacle.PBKDF2Hasher(salt)
     hasher_b = muteacle.ScryptHasher(salt)
     self.assertNotEqual(hasher_a, hasher_b)
Example #7
0
def test_append_log_scrypt(repository, items):
    salt = token_bytes(salt_length)
    hasher = muteacle.ScryptHasher(salt)
    repository.append_log(items, hasher)
Example #8
0
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import pdb
import muteacle
from datetime import datetime, timedelta
from secrets import token_bytes

# Examples
repo_sqlite = muteacle.SQLiteRepository()
salt_length = 32
items_a = (b'A1', b'A2', b'A3')
items_b = (b'B1', b'B2', b'B3')
hasher_s1 = muteacle.ScryptHasher(token_bytes(salt_length))
hasher_s2 = muteacle.ScryptHasher(token_bytes(salt_length), keylen=64)


def dump_sqlrepo_log_table(sqlrepo):
    if not isinstance(sqlrepo, muteacle.SQLiteRepository):
        raise TypeError('this helper is only for SQL repositories')
    scr = 'SELECT * FROM MuteacleLog'
    cur = sqlrepo.get_db_conn().execute(scr)
    rows = cur.fetchall()
    print('all log entries:', rows, sep='\n')
    return rows


def dump_sqlrepo_hasher_table(sqlrepo):
    if not isinstance(sqlrepo, muteacle.SQLiteRepository):