Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
370 B
9
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 = str(int(bin(i)[2:])).zfill(4)[:4]
    nib2 = str(int(bin(i)[2:])).zfill(8)[4:]
    y.append (hex(int(nib1+'0000')))
    y.append (hex(int(nib2+'0000')))

  return y

print(ChartoNibbledHex("Hello world"))