Пример #1
0
def intestinize(password, birthdate):
    salt = sha3(birthdate)
    time_cost = get_time_cost(birthdate)
    digest = Argon2id(time_cost=time_cost, salt=salt).hash(password)
    del password
    digest = digest[digest.rfind('$')+1:]
    digest = digest.encode('utf-8') # for concatenating with checksum
    checksum = sha3(digest)[-4:]
    digest += checksum
    return digest
Пример #2
0
 def test_sha3_empty(self):
     value = ''
     digest = tools.sha3(value)
     self.assertEqual(
         digest,
         b'\xa7\xff\xc6\xf8\xbf\x1e\xd7fQ\xc1GV\xa0a\xd6b\xf5\x80\xffM\xe4;I\xfa\x82\xd8\nK\x80\xf8CJ'
     )
Пример #3
0
 def test_sha3_notbytes(self):
     value = 'bytesbytes'
     digest = tools.sha3(value)
     self.assertEqual(
         digest,
         b'\xcb\t\xa2\x8f\x8f\x8c?u\xcef\x97\x1aI\xcbja\xab\xc1\xb8\xcb\x95(\x96u+l\'m\xa7\xb5}"'
     )
Пример #4
0
def setup(master_password, birthdate):
    success = True
    # We want to get rid of the master password ASAP so we hash it (512 to keep entropy)
    digest = sha3(master_password)
    del master_password
    digest = intestinize(digest, birthdate)
    try:
        with open(working_path + sep + 'MasterPasswordDigest.txt','wb') as f:
            f.write(digest)
    except Exception as e:
        return not success, "File writing error (" + str(e) + ")"
    else:
        return success, "The digest file has been saved. You can now use PassGen."
Пример #5
0
def intestinize(masterpassworddigest, website_name, short):
    """
        Returns a string (not bytes) of readable characters
    """
    Input = masterpassworddigest + website_name
    # can't bruteforce password really so we set time_cost to 1
    salt = sha3(website_name)
    length = 24  # for 24 characters
    if short:
        length = 8  # for 8 characters
    digest = Argon2id(salt=salt,
                      hash_len=ceil(length / 1.33),
                      memory_cost=33554,
                      time_cost=1).hash(Input)
    del Input, masterpassworddigest, website_name
    digest = digest[digest.rfind('$') + 1:]
    return digest[:length]
Пример #6
0
 def test_sha3_notbytes_hexa(self):
     value = 'bytesbytes'
     digest = tools.sha3(value, hexa=True)
     self.assertEqual(
         digest,
         'cb09a28f8f8c3f75ce66971a49cb6a61abc1b8cb952896752b6c276da7b57d22')
Пример #7
0
def checksumIsValid(digest):
    try:
        checksum = sha3(digest[:-4])[-4:]
    except TypeError:
        return False # digest is not bytes
    return digest[-4:] == checksum