def test_crypto_pwhash_salsa208sha256_str(self): password = '******' pwhash = pysodium.crypto_pwhash_scryptsalsa208sha256_str(password) self.assertEqual( pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify( pwhash, password), None) with self.assertRaises(ValueError): pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify( pwhash, 'wrongpassword')
def test_crypto_pwhash_scryptsalsa208sha256_str_verify(self): passwd = b'Correct Horse Battery Staple' other_passwd = b'correct horse battery staple' # Use very small limits to avoid burning resources in CI mem_limit = 32 * 1024 ops_limit = 1024 storage_string = pysodium.crypto_pwhash_scryptsalsa208sha256_str(passwd, ops_limit, mem_limit) pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify(storage_string, passwd) self.assertRaises(ValueError, pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify, storage_string, other_passwd) self.assertRaises(ValueError, pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify, storage_string[:-1], passwd) self.assertRaises(ValueError, pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify, storage_string + b'a', passwd)
def test_crypto_pwhash_scryptsalsa208sha256_str_verify(self): passwd = b'Correct Horse Battery Staple' other_passwd = b'correct horse battery staple' # Use very small limits to avoid burning resources in CI mem_limit = 16777216 ops_limit = 32768 storage_string = pysodium.crypto_pwhash_scryptsalsa208sha256_str(passwd, ops_limit, mem_limit) pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify(storage_string, passwd) self.assertRaises(ValueError, pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify, storage_string, other_passwd) self.assertRaises(ValueError, pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify, storage_string[:-1], passwd) self.assertRaises(ValueError, pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify, storage_string + b'a', passwd)
def test_crypto_pwhash_salsa208sha256_str(self): password = '******' pwhash = pysodium.crypto_pwhash_scryptsalsa208sha256_str(password) self.assertEqual(pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify(pwhash, password), None) with self.assertRaises(ValueError): pysodium.crypto_pwhash_scryptsalsa208sha256_str_verify(pwhash, 'wrongpassword')