sample_python_spake2.py 448 B

12345678910111213141516171819202122
  1. from binascii import hexlify
  2. from spake2 import SPAKE2_A, SPAKE2_B
  3. shared_password = b"This Is The Password!"
  4. alice = SPAKE2_A(shared_password)
  5. alice_msg = alice.start()
  6. bob = SPAKE2_B(shared_password)
  7. bob_msg = bob.start()
  8. # Alice and Bob exchange their messages...
  9. alice_key = alice.finish(bob_msg)
  10. bob_key = bob.finish(alice_msg)
  11. print("alice_key:", hexlify(alice_key))
  12. print(" bob_key:", hexlify(bob_key))
  13. assert alice_key == bob_key