Untitled
unknown
plain_text
2 years ago
432 B
14
Indexable
Never
import math def ChartoNibbledHex(a): x,y=[],[] for i in a: x.append(ord(i)) # convert string character to ascii value for i in x: nib1 = zfl(str(int(bin(i)[2:])),8)[:4] nib2 = zfl(str(int(bin(i)[2:])),8)[4:] y.append (hex(int(nib1+'0000'))) y.append (hex(int(nib2+'0000'))) return y def zfl(s, width): return '{:0>{w}}'.format(s, w=width) print(ChartoNibbledHex("Hello world"))