Snippets

Zhiwei Li hexstr to java byte array

Created by Zhiwei Li

File hex_bytes.py Added

  • Ignore whitespace
  • Hide word diff
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import binascii
+
+a = 'D499E3623734F6CEC432D6B148286CEB'
+aa = binascii.unhexlify(a)
+print(aa)
+
+ret = []
+for x in aa:
+    if x > 127:
+        ret.append('%d, ' % (x-256))
+    else:
+        ret.append('%d, ' % x)
+
+result = ''.join(ret)
+print(result)
+        
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.