magic-wormhole/bin/receive_text.py

16 lines
479 B
Python

from __future__ import print_function
import time, json
from wormhole.blocking.transcribe import Receiver
APPID = "lothar.com/wormhole/text-xfer"
# we're receiving
data = json.dumps({"message": "ok"}).encode("utf-8")
r = Receiver(APPID, data)
r.set_code(r.input_code("Enter receive-text wormhole code: "))
start = time.time()
them_bytes = r.get_data()
them_d = json.loads(them_bytes.decode("utf-8"))
print(them_d["message"])
print("elapsed time: %.2f" % (time.time() - start))