首页 > 其他分享 >中国供应商字体解密

中国供应商字体解密

时间:2024-12-06 09:55:31浏览次数:9  
标签:供应商 解密 rlineto &# 字体 Path path data rrcurveto

https://www.gys.cn/buy/5420348615.html

字体是由坐标画出来的,关键词:rmoveto, rlineto, rrcurveto等

""""
<CharString name="uni100d1">
    126 15 -1 rmoveto
    0 0 rlineto
    -2 7 rlineto
    43 15 25 25 7 35 rrcurveto
    0 0 rlineto
    -11 -11 -12 -6 -13 0 rrcurveto
    0 0 rlineto
    -27 3 -15 18 -2 33 rrcurveto
    0 0 rlineto
    1 41 17 21 33 1 rrcurveto
    0 0 rlineto
    35 -1 18 -25 1 -49 rrcurveto
    0 0 rlineto
    0 -59 -33 -36 -66 -12 rrcurveto
    75 95 rmoveto
    0 0 rlineto
    2 53 -10 26 -22 -1 rrcurveto
    0 0 rlineto
    -19 0 -9 -16 0 -32 rrcurveto
    0 0 rlineto
    -1 -33 10 -16 21 1 rrcurveto
    0 0 rlineto
    11 1 9 6 8 11 rrcurveto
    endchar
</CharString>
"""
import ddddocr
import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches


# 定义路径命令
commands = [
    ("rmoveto", 126, 15, -1),
    ("rlineto", 0, 0),
    ("rlineto", -2, 7),
    ("rrcurveto", 43, 15, 25, 25, 7, 35),
    ("rlineto", 0, 0),
    ("rrcurveto", -11, -11, -12, -6, -13, 0),
    ("rlineto", 0, 0),
    ("rrcurveto", -27, 3, -15, 18, -2, 33),
    ("rlineto", 0, 0),
    ("rrcurveto", 1, 41, 17, 21, 33, 1),
    ("rlineto", 0, 0),
    ("rrcurveto", 35, -1, 18, -25, 1, -49),
    ("rlineto", 0, 0),
    ("rrcurveto", 0, -59, -33, -36, -66, -12),
    ("rmoveto", 75, 95),
    ("rlineto", 0, 0),
    ("rrcurveto", 2, 53, -10, 26, -22, -1),
    ("rlineto", 0, 0),
    ("rrcurveto", -19, 0, -9, -16, 0, -32),
    ("rlineto", 0, 0),
    ("rrcurveto", -1, -33, 10, -16, 21, 1),
    ("rlineto", 0, 0),
    ("rrcurveto", 11, 1, 9, 6, 8, 11),
    ("endchar",),
]

# 初始化起始点
x, y = 0, 0

# 创建路径数据
path_data = []
for command in commands:
    if command[0] == "rmoveto":
        x += command[1]
        y += command[2]
        path_data.append((Path.MOVETO, (x, y)))
    elif command[0] == "rlineto":
        x += command[1]
        y += command[2]
        path_data.append((Path.LINETO, (x, y)))
    elif command[0] == "rrcurveto":
        x1, y1 = x + command[1], y + command[2]
        x2, y2 = x1 + command[3], y1 + command[4]
        x3, y3 = x2 + command[5], y2 + command[6]
        path_data.append((Path.CURVE4, (x1, y1)))
        path_data.append((Path.CURVE4, (x2, y2)))
        path_data.append((Path.CURVE4, (x3, y3)))
        x, y = x3, y3

# 创建路径
codes, verts = zip(*path_data)
path = Path(verts, codes)

# 创建图形
fig, ax = plt.subplots()
patch = patches.PathPatch(path, facecolor="black", lw=2)  # 使用黑色填充
ax.add_patch(patch)
ax.set_aspect("equal")
ax.autoscale()

# 保存图形
plt.savefig("charstring.png")

# 使用 ddddocr 识别图像中的字符
ocr = ddddocr.DdddOcr()
with open("charstring.png", "rb") as f:
    img_bytes = f.read()
result = ocr.classification(img_bytes)

print("识别结果:", result)

画出来的结果:

ddddocr识别的结果:

完整代码示例:

import io
import ddddocr
import base64

from fontTools.ttLib import TTFont
from fontTools.pens.basePen import BasePen
import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches


ocr = ddddocr.DdddOcr()


class MatplotlibPen(BasePen):
    def __init__(self, glyphSet):
        super().__init__(glyphSet)
        self.path_data = []

    def _moveTo(self, p0):
        self.path_data.append((Path.MOVETO, p0))

    def _lineTo(self, p1):
        self.path_data.append((Path.LINETO, p1))

    def _curveToOne(self, p1, p2, p3):
        self.path_data.append((Path.CURVE4, p1))
        self.path_data.append((Path.CURVE4, p2))
        self.path_data.append((Path.CURVE4, p3))

    def _closePath(self):
        self.path_data.append((Path.CLOSEPOLY, self.path_data[0][1]))


def get_font_data(font_str):
    """获取解密字体"""
    font_data = base64.b64decode(font_str)
    font = TTFont(io.BytesIO(font_data))
    font.saveXML("font.xml")

    result = {}
    # 获取字符的路径数据
    glyph_set = font.getGlyphSet()
    glyph_names = font.getGlyphNames()
    for glyph_name in glyph_names:
        glyph = glyph_set[glyph_name]

        # 使用 MatplotlibPen 解析路径数据
        pen = MatplotlibPen(glyph_set)
        glyph.draw(pen)

        # 检查 path_data 是否为空
        if not pen.path_data:
            continue

        # 创建路径
        codes, verts = zip(*pen.path_data)
        path = Path(verts, codes)

        # 创建图形
        fig, ax = plt.subplots()
        patch = patches.PathPatch(path, facecolor="black", lw=2)  # 使用黑色填充
        ax.add_patch(patch)
        ax.set_aspect("equal")
        ax.autoscale()

        # 保存图形
        plt.savefig("charstring.png")

        # 使用 ddddocr 识别图像中的字符
        with open("charstring.png", "rb") as fr:
            img_bytes = fr.read()
        ret = ocr.classification(img_bytes)

        print("识别结果:", glyph_name, ret)
        result[glyph_name] = ret.upper()

    print(result)
    return result


if __name__ == "__main__":
    font_str = "T1RUTwAJAIAAAwAQQ0ZGIIpi0aIAAATIAAADjk9TLzJlk+AaAAABAAAAAGBjbWFwACgMUgAABAQAAACkaGVhZCZ5+TwAAACcAAAANmhoZWEA3wBMAAAA1AAAACRobXR4B3IAAAAACFgAAAAgbWF4cAAIUAAAAAD4AAAABm5hbWUKXYQxAAABYAAAAqNwb3N0AAMAAAAABKgAAAAgAAEAAAABAACUNrWcXw889QADAQAAAAAA43NdSAAAAADjc11IAAT//wB4ALUAAAADAAIAAAAAAAAAAQAAAN3/xQAAAH4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAgAAFAAAAgAAAADAH4B9AAFAAACigK7AAAAjAKKArsAAAHfADEBAgAAAAAAAAAAAAAAAIAAAAEAAAAAAAAAAAAAAABYWFhYAEAAywDRAN3/xQAAALUAAQAAAAEAAAAAAG8AtQAAAAAAAAAAACIBngABAAAAAAAAAAEAQgABAAAAAAABAAwAAAABAAAAAAACAAYAJAABAAAAAAADABUAxgABAAAAAAAEABMANgABAAAAAAAFAAsApQABAAAAAAAGABIAbwABAAAAAAAHAAEAQgABAAAAAAAIAAEAQgABAAAAAAAJAAEAQgABAAAAAAAKAAEAQgABAAAAAAALAAEAQgABAAAAAAAMAAEAQgABAAAAAAANAAEAQgABAAAAAAAOAAEAQgABAAAAAAAQAAwAAAABAAAAAAARAAYAJAADAAEECQAAAAIAYQADAAEECQABABgADAADAAEECQACAAwAKgADAAEECQADACoA2wADAAEECQAEACYASQADAAEECQAFABYAsAADAAEECQAGACQAgQADAAEECQAHAAIAYQADAAEECQAIAAIAYQADAAEECQAJAAIAYQADAAEECQAKAAIAYQADAAEECQALAAIAYQADAAEECQAMAAIAYQADAAEECQANAAIAYQADAAEECQAOAAIAYQADAAEECQAQABgADAADAAEECQARAAwAKk9wZW5UeXBlU2FucwBPAHAAZQBuAFQAeQBwAGUAUwBhAG4Ac01lZGl1bQBNAGUAZABpAHUAbU9wZW5UeXBlU2FucyBNZWRpdW0ATwBwAGUAbgBUAHkAcABlAFMAYQBuAHMAIABNAGUAZABpAHUAbU9wZW5UeXBlU2Fuc01lZGl1bQBPAHAAZQBuAFQAeQBwAGUAUwBhAG4AcwBNAGUAZABpAHUAbVZlcnNpb24gMC4xAFYAZQByAHMAaQBvAG4AIAAwAC4AMSA6T3BlblR5cGVTYW5zIE1lZGl1bQAgADoATwBwAGUAbgBUAHkAcABlAFMAYQBuAHMAIABNAGUAZABpAHUAbQAAAAACAAMAAQAAABQAAwAKAAAANAAEACAAAAAEAAQAAQAAAAD//wAAAAD//wAAAAEAAAAAAAwAAAAAAHAAAAAAAAAACAAAAAAAAAAAAAAAAAABAMsAAQDLAAAAAQABAMwAAQDMAAAAAgABAM0AAQDNAAAAAwABAM4AAQDOAAAABAABAM8AAQDPAAAABQABANAAAQDQAAAABgABANEAAQDRAAAABwADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAEAQABAQETT3BlblR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WJkgW2mqSkkq4Ii4sFgIB/hX6LCIuLBXCOfJ2JrAiLiwWMtJygrIwIi4sFroqdcoxaCIuLBYtQamdJfwjW6hWLiwWNwIGldYoIi4sFeIuCe4trCIuLBYpqlXugjAiLiwWWjJSRk5YIDgAABAAAAAB+AAAAfgAAAH4AAAB+AAAAfgAAAH4AAAB+AAA="
    result = get_font_data(font_str)
    # 15014777339
    # "&#x100cb;&#x100cc;&#x100cd;&#x100cb;&#x100ce;&#x100cf;&#x100cf;&#x100cf;&#x100d0;&#x100d0;&#x100d1;"
    txt = "&#x100cb;&#x100cc;&#x100cd;&#x100cb;&#x100ce;&#x100cf;&#x100cf;&#x100cf;&#x100d0;&#x100d0;&#x100d1;"
    for key, value in result.items():
        key = key.replace("uni", "&#x").lower() + ";"
        txt = txt.replace(key, value)
    print(txt)

输出结果:

标签:供应商,解密,rlineto,&#,字体,Path,path,data,rrcurveto
From: https://www.cnblogs.com/wangshx666/p/18589976

相关文章

  • “掌握AWD:解密全轮驱动的终极性能“
    AWD攻防战(Attack-DefenseWar)是一种常见的渗透测试形式,也称为红蓝对抗,是为了模拟真实的网络安全攻防情况而进行的比赛或训练。AWD攻防战通常会分为两个团队:红队和蓝队。红队是攻击方,负责发起各种攻击以获取敌方系统的控制权或敏感信息。蓝队是防守方,负责保护自己的系统,发现并......
  • vue项目中使用icon字体图标
    1、安装vite-plugin-svg-icons命令如下,-D表示该依赖添加在package.json里面的devDependencies。devDependencies下的依赖包,只是我们在本地或开发坏境下运行代码所依赖的,若发到线上,其实就不需要devDependencies下的所有依赖包;(比如各种loader,babel全家桶及各种webpack的插件等)......
  • c# - java公私钥 转 c# net 公私钥做 RSA 加解密操作
    1.背景java和c#语言的公私钥格式是不同的,需要专门转换后才可以使用2.c#工具类usingSystem;usingSystem.Security.Cryptography;usingSystem.Text;usingOrg.BouncyCastle.Crypto.Parameters;usingOrg.BouncyCastle.Security;namespaceHypj.Logic.NCAPI{pu......
  • 管家婆财贸ERP BR028.集团供应商运费往来明细表
    最低适用版本:C系列23.5插件简要功能说明:多组织机构适用统计各组织机构运费往来明细数据更多细节描述见下方详细文档插件操作视频:进销存类定制插件--集团供应商运费往来明细表插件详细功能文档:1.应用中心增加菜单【集团供应商运费往来明细表】a.b.查询......
  • 比亚迪强势要求供应商降价10%,车企“价格战”何时是个头?
    在汽车行业,一场旷日持久的“价格战”似乎永远没有尽头。刚刚有所缓和的市场氛围,随着比亚迪的一纸邮件再次被推向风口浪尖。据悉,比亚迪已向供应商发出通知,要求其供货产品在2025年降价10%,这一消息迅速在网络上引发热议,不少人对车企间的竞争态势表示担忧。比亚迪的这封邮件不仅......
  • gnuplot/matplotlib论文作图尺寸、字体
    出版社:iop,aip,aps等作图时设置成相对通用的尺寸和规范可以免去许多麻烦,大到修改尺寸和颜色,小到添加(a),(b),(c)等序号。不同的工具画出来的图效果又有不同。字体:Arial1.单栏图片需要调整图片本身大小与latex中的大小;同时,gnuplot中的图比matplotlib画出来的要小一些......
  • 说说页面中字体渲染规则是怎样的?会有哪些因素影响字体的渲染?
    网页中字体的渲染是一个复杂的过程,受到多种因素的影响。总的来说,浏览器会根据一系列规则和设置来决定如何显示文本。以下是主要的渲染规则和影响因素:渲染规则:CSS继承和层叠:字体样式可以继承自父元素,也可以被子元素的样式覆盖。CSS的层叠规则决定了哪个样式最终生效。fon......
  • B4X编程语言:B4X控件的字体属性(Font / Typeface)
            除B4XView类型的控件外,B4A控件的字体属性是Typeface,B4J控件的字体属性是Font。B4XView类型的控件无论在B4A、B4J还是B4i中,其字体属性均是Font。    一、B4A控件的字体属性Typeface        Typeface属性用于设置或获取B4A控件文本字体,获取字......
  • H5-19 字体属性
    CSS字体属性定义字体,颜色、大小、加粗、文字样式1、color规定文本的颜色div{color:red;}div{color:#fff000}  最常用div{color:rgb(255,0,0)}div{color:rgba(255,0,0,0-1中间任意数值)}2、font-size设置文本的大小能否管理文字的大小,在......
  • 跨语言国密SM4加解密实战:Java与Golang无缝对接
    概述本文详细介绍了如何在Java和Golang中使用SM4算法进行对称加密和解密操作。通过使用CBC模式和PKCS5填充,成功实现了跨语言的数据加密和解密。无论是Java加密后在Golang解密,还是Golang加密后在Java解密,均通过了测试验证,保证了两种语言在处理国密SM4算法时的兼容性和一致性。前......