Skip to content

Instantly share code, notes, and snippets.

@xja
Created June 10, 2022 00:31
Show Gist options
  • Save xja/7b3d1db1723f11c433c4706c8408a999 to your computer and use it in GitHub Desktop.
Save xja/7b3d1db1723f11c433c4706c8408a999 to your computer and use it in GitHub Desktop.
from random import randint
rn = [randint(0, 255) for _ in range(14)]
rn[1] = 0xE7
rn[5] = 0x03
arg2 = [0xc, 6]
arg3 = [3, 0xf3]
for i in range(2):
a1 = 0
for j in range(4):
a1 <<= 8
a1 += rn[i * 4 + j]
rn[9+3*i] = ((a1 >> arg2[i]) & 0xff) ^ ((a1 & 0xff) | arg3[i])
rs = ''
for i in range(14):
rs += f'{rn[i]:02X}'
if i % 2:
rs += '-'
cx = 0x42
dx = 0xBE
for s in rs:
if s != '-':
dx += ord(s)
if dx > 0xFF:
dx -= 0xFF
cx += dx
if cx > 0xFF:
cx -= 0xFF
rs += f'{cx:02X}{dx:02X}'
print(rs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment