# -*- coding: iso-8859-1 -*- # mk, 13.9.08 def s2h(s): H =['0','1','2','3','4','5','6','7', '8','9','a','b','c','d','e','f'] # Hex-Ziffern i = 0 # Laufvariable a = '' # Ausgabestring L = len(s) while i < L: n = ord(s[i]) s0 = n%16 # 1 -Stelle s1 = n/16 # 16-Stelle a = a+' '+H[s1]+H[s0] i = i+1 return a def s2b(s): B =['0000','0001','0010','0011','0100','0101','0110','0111', '1000','1001','1010','1011','1100','1101','1110','1111'] # Binär-Muster i = 0 # Laufvariable a = '' # Ausgabestring L = len(s) while i < L: n = ord(s[i]) s0 = n%16 # 1 -Stelle s1 = n/16 # 16-Stelle a = a+' '+B[s1]+' '+B[s0] i = i+1 return a