From b91c6b5330eca005dfc0f505c1249f2a91cbd90b Mon Sep 17 00:00:00 2001 From: xiaoqidun Date: Wed, 8 Jul 2026 15:47:53 +0800 Subject: [PATCH] =?UTF-8?q?docs(=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AD=BE=E5=90=8D=E9=AA=8C=E8=AF=81=E9=83=A8?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9749449..8d67c29 100644 --- a/README.md +++ b/README.md @@ -59,5 +59,51 @@ func main() { } ``` +# 签名验证 +```go +package main + +import ( + "log" + "os" + + "github.com/xiaoqidun/ofdgo" +) + +func main() { + // 1. 打开OFD文件 + data, err := os.ReadFile("test.ofd") + if err != nil { + log.Fatal(err) + } + // 2. 验证OFD签名 + reports, err := ofdgo.VerifySignaturesBytes(data) + if err != nil { + log.Fatal(err) + } + // 3. 判断验证结果 + if len(reports) == 0 { + log.Println("文件未发现签名") + return + } + valid := true + for _, report := range reports { + if report.Valid { + log.Printf("签名%s验证通过", report.ID) + continue + } + valid = false + if report.Error == "" { + log.Printf("签名%s验证失败", report.ID) + } else { + log.Printf("签名%s验证失败: %s", report.ID, report.Error) + } + } + if !valid { + os.Exit(1) + } +} +``` + # 授权协议 -本项目使用 [Apache License 2.0](https://github.com/xiaoqidun/ofdgo/blob/main/LICENSE) 授权协议 \ No newline at end of file +本项目使用 [Apache License 2.0](https://github.com/xiaoqidun/ofdgo/blob/main/LICENSE) 授权协议