The code is for learning and communication only , Do not use for illegal purposes
from fontTools.ttLib import TTFont
import json
import xmltodict
font = TTFont("./1.woff")
font.saveXML("1.xml")
xml_file = open("1.xml", 'r', encoding="utf-8")
xml_str = xml_file.read()
json_data = xmltodict.parse(xml_str, encoding='utf-8')
info = json.loads(json.dumps(json_data))
fontMaps = info['ttFont']['cmap']['cmap_format_4'][0]['map']
# Ciphertext
enstr = "H2wHeleH2we"
destr = ""
for _ in range(len(enstr)):
hexAscii = hex(ord(enstr[_:_ + 1]))
for fontMap in fontMaps:
if str(fontMap['@code']) == str(hexAscii):
destr += ‘’
break
print(" Encrypted ciphertext :{}\n Decrypt plaintext :{}".format(enstr, destr))