| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import sys
- import pathlib
- import asyncio
- test_file = pathlib.Path(__file__)
- project = test_file.parent.parent
- sys.path.append(str(project))
- import server_source as source
- from test import test
- async def main():
- print("Generating password...")
- password = await source.password.from_plain_text("Sample")
- print(repr(password))
- print("Lenght: " + str(len(password.result())))
- print()
- print("Checking password...")
- test(await password.compare("Sample"), True)
- test(await password.compare("Samples"), False)
- print()
- print("Generating other password...")
- second_password = await source.password.from_plain_text("other")
- print(repr(second_password))
- print()
- print("Checking password...")
- test(await second_password.compare("other"), True)
- test(await second_password.compare("other_fail"), False)
- print()
- print("Generating other password with same content other salt...")
- variant = await source.password.from_plain_text("Sample")
- print(repr(variant))
- print()
- print("Checing it...")
- test(await variant.compare("Sample"), True)
- test(await password.compare("Sample"), True)
- print()
- print("Regenerating password from hash...")
- restore = await source.password.from_hash(password.result())
- print("Old: " + repr(password))
- print("Restored: " + repr(restore))
- print()
- print("Validating...")
- test(await restore.compare("Sample"), True)
- test(await restore.compare("Sampled"), False)
- print()
- asyncio.run(main())
|