Skip to content

Instantly share code, notes, and snippets.

@salrashid123
Last active August 26, 2017 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salrashid123/b39e2ad383169290c9f64edfcb70f8d5 to your computer and use it in GitHub Desktop.
Save salrashid123/b39e2ad383169290c9f64edfcb70f8d5 to your computer and use it in GitHub Desktop.
def w(filename):
req = echo_pb2.EchoRequest(firstname='john', lastname='doe')
msg = binascii.b2a_hex(req.SerializeToString())
frame = '00' + hex(len(msg)/2).lstrip("0x").zfill(8) + msg
print 'Raw Encode: ' + frame
f = open(filename, "wb+")
f.write(binascii.a2b_hex(frame))
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment