21 lines
1.0 KiB
Python
21 lines
1.0 KiB
Python
"""Public deterministic interop fixture, never live session material."""
|
|
import json
|
|
from pathlib import Path
|
|
from app.mobile.wifi import wifi_cipher
|
|
|
|
def generate():
|
|
secret = bytes(range(32))
|
|
channel = '0123456789abcdef0123456789abcdef'
|
|
request = b'{"device_id":"public-test-device"}'
|
|
response = b'{"device_id":"public-test-device","ready":true}'
|
|
c, s = wifi_cipher(secret, channel, server=False), wifi_cipher(secret, channel, server=True)
|
|
return dict(secret=secret.hex(), channel_id=channel, request=request.hex(), response=response.hex(),
|
|
client_record=c.encrypt(request).hex(), server_record=s.encrypt(response).hex())
|
|
|
|
if __name__ == '__main__':
|
|
root = Path(__file__).resolve().parents[2]
|
|
raw = json.dumps(generate(), indent=2) + '\n'
|
|
for path in [root / '核桃派软件源代码/tests/fixtures/protocol-wifi-v1.json',
|
|
root / '移动端相关内容/安卓app/安卓程序源代码/sharedCore/src/jvmTest/resources/protocol-wifi-v1.json']:
|
|
path.write_text(raw, encoding='utf-8')
|