更新日志
v1.3.0 (2026-10-19)
✨ 新功能
- 新增 SM2 的 ASN.1 密文与签名格式:
Sm2CipherMode新增ASN1C1C2C3和ASN1C1C3C2,密文可以是 DER 编码的SEQUENCE { x INTEGER, y INTEGER, C2 OCTET STRING, C3 OCTET STRING },即 BouncyCastle、Java 与多数国密网关的输出格式,不再局限于C1 || C2 || C3、C1 || C3 || C2的裸字节排列;新增Sm2SingMode(默认ASN1,可选Bytes)与SetSingMode,签名既可以是 DER 的SEQUENCE { r, s },也可以是固定 64 字节的r || s;两种格式均使用cryptobyte解析,数据被截断或不是合法 DER 时直接返回错误,而不是被悄悄误读;NewSm2KeyPair保持ASN1为默认值(by @Web-Coke in #40) - 将摩斯电码字母表补齐到 ITU-R M.1677-1 全表及国际扩展字符:新增
¡、¿、å/Å、ä/Ä、é/É、ñ/Ñ、ó/Ó、ö/Ö、ú/Ú,编码取自 codigomorse.org,并标注每组字符对应的 ITU 条款来源,同时把/归入标点分组;注意有两个已有映射发生变化:<由.--.-改为.--.--(.--.-现已分配给å),\n改为.-..-..,不再与\r共用同一编码;用 v1.2.3 编码的这两类字符,解码结果会随之变化(by @htlsmilework in #42)
🐛 修复
- 修复 ascii85 解码在存在
z缩写时截断输出的问题:encoding/ascii85会把全零的四字节分组编码成单个z,本库的编码器同样如此,但解码器按严格的 5:4 比例用字符数重算目标长度,并把标准库给出的正确结果截断到该长度,导致五个零字节往返后只剩两个、八个零字节只剩一个,且不报任何错误;现在z不再计入该比例而按四字节计算,目标缓冲区也按缩写所隐含的展开量分配(by @youdie006 in #44) - 修复 ascii85 解码在四个及以上零分组时失败的问题:上述长度修复之后,
u补齐仍使用len(src)%5,存在z缩写时最后一组可能只剩一个字符,而encoding/ascii85会拒绝这种输入——十六个零字节(编码为zzzz)因此完全无法解码;现在两个解码器都按非z的长度补齐(by @youdie006 in #47) - 修复 base58、base62 流式编解码结果与批量接口不一致的问题:两种编码都把输入视为一个大整数,无法拆成互相独立的块,但流式编码器每 8 字节编一次、流式解码器每 1024 字节解一次,导致
Encode.FromFile(...).ByBase58()、ByBase62()与同样数据的FromBytes()结果不同,且该结果无法解码回原文;现在流式编码器按文档承诺缓存输入并在Close时一次性编码,解码器读取全部输入后一次性解码,并在消费过程中释放缓冲区(by @Shaisolaris in #48) - 修复密钥对拒绝其他工具生成的密钥、并在算法不匹配时 panic 的问题:此前只有当密钥与
GenKeyPair的输出逐字节一致(即PUBLIC KEY/PRIVATE KEYPEM 块中承载 PKIX 或 PKCS#8 DER)时才会被接受;多数 SM2、Ed25519 生成器输出的 base64 或原始密钥材料会失败于invalid public key: <nil>或难以理解的 ASN.1 错误,把 RSA 密钥传给 Ed25519 密钥对则会因类型断言结果未检查而 panic(#41);现在所有Parse*、Format*、Set*方法统一经过一个选择器,依次尝试 PEM、base64(四种字母表、可带或不带填充)、十六进制与原始密钥材料,由各算法自己的解析器决定哪种解释成立——Ed25519 接受 PKIX/PKCS#8 DER、32 字节种子和 64 字节私钥,SM2 接受 PKIX/PKCS#8 DER、65 字节非压缩点与 32 字节标量,RSA 接受 PKIX/PKCS#1 DER;SM2 的密钥格式化改用本地 SPKI/PKCS#8 编码器(crypto/x509不支持 SM2),输出仍可被 OpenSSL、Java 解析;Set*Key接受 PEM 并归一化输出,算法或方向不符的 PEM 块在解析前即以UnsupportedKeyFormatError拒绝(提示the parsed key is an RSA key, not an Ed25519 key),错误信息不再打印<nil>,Compress*Key改用pem.Decode而不再做字符串裁剪,因此可处理可选的块头,SM2 私钥标量也会校验落在[1, n-1]区间——此前d = 0会产生没有公钥点的密钥(by @gouguolei in 012269d)
⚡ 性能优化
- 摩斯解码只构建一次反向字母表,不再逐字符扫描:
StdDecoder.Decode为每个符号遍历整张StdAlphabet直到命中,使解码成为 O(n × 89) 而非 O(n),CPU 采样中有 53% 的时间耗在 map 遍历上;现在按 base45、base91 已有的做法在init()中一次性构建反查表,几何平均耗时下降 89.21%(4096 字符:1222µs → 103µs),内存分配次数不变;这次扫描还让解码结果不确定——有七个编码由大小写成对共享(.--.-同时属于Å和å,ä、é、ñ、ó、ö、ú同理),而 map 遍历顺序随机,导致.--.-有 62% 的概率解成Å,这些字符的编码再解码并不无损;反查表把这类冲突统一解析为小写形式,这也是Encode唯一能产生的结果(by @darakanoit in #46)
🔧 重构
- 将密钥序列化统一收敛到包级函数变量:
marshalPKIXPublicKey、marshalPKCS8PrivateKey现在是包装crypto/x509的变量,marshalSm2PublicKey、marshalSm2PrivateKey包装本地的 SM2 编码器,从而可以在测试中模拟Format*Key的错误分支——对于已经解析成具体类型的密钥,crypto/x509永远不会失败;RSA、Ed25519、SM2 的格式化均改为调用它们(by @gouguolei in e314c99 6ad47b4 0769ea0 2c9ad5a) - 简化 RSA 流式验签并移除未使用的流式缓冲区:
rsa.StreamVerifier.verify只返回error,不再返回一个在无错误时恒为 true 的valid;unicode.StreamEncoder、unicode.StreamDecoder去掉未使用的固定[512]byte缓冲区;摩斯电码的错误信息改用字符串字面量,不再用没有占位符的fmt.Sprintf(by @gouguolei in 68dad92) - 修正
SetSingMode的反向断言并显式初始化 SM2 默认值:clamp 测试在调用SetSingMode(Bytes)后期望SingMode仍为ASN1,这与 setter 直接赋值的实现相矛盾,而NewSm2KeyPair之前依赖零值恰好等于ASN1;现在构造函数显式设置SingMode: ASN1,测试同时断言两个方向(by @gouguolei in 079efab) - 清理并补充测试:从 24 个测试文件中移除未使用的变量与重复用例,新增
key_format_test.go、key_test.go覆盖密钥材料辅助函数、各种UnsupportedKeyFormatError提示及公开 API 的拒绝路径,并覆盖 SM2 的 DER 与私钥标量区间分支,keypair语句覆盖率提升至 97.7%(by @gouguolei in 372209d 12c3e11)
🚀 持续集成
- 新增 golangci-lint 工作流与配置:
lint.yml在向 master 推送和发起 PR 时运行固定为v2.15.0的golangci-lint-action@v9,权限仅contents: read;.golangci.yml在标准规则集之外启用misspell、unconvert、unparam、whitespace,关闭过于主观的staticcheck风格检查(ST1000–ST1022、QF1001),并为errcheck排除(io.Seeker).Seek(回卷流按设计是尽力而为);README 以该工作流的状态徽章替换 Go Report Card 徽章(by @gouguolei in 1487675 0517244)
📝 文档
- README 图片改为从仓库读取,不再依赖文档站:Logo、GVP 与 G-Star 横幅、JetBrains 图标均指向
assets/,中文、英文、日文三个 README 不再依赖dongle.go-pkg.com(by @gouguolei in 19bffd5)
What's Changed (19)
- add ASN.1 support by @Web-Coke in #40
- fix(morse): Add some code from codigomorse.org and correct some repetitive code by @htlsmilework in #42
- Decode the ascii85 z shortcut without truncating by @youdie006 in #44
- perf(morse): Derive the reverse alphabet once instead of scanning it per symbol by @darakanoit in #46
- Pad the ascii85 partial group without counting z shortcuts by @youdie006 in #47
- fix(coding): encode and decode base58 and base62 streams as a whole by @Shaisolaris in #48
- fix(keypair): correct SingMode test assertion and add explicit default by @gouguolei in 079efab
- fix(keypair): accept externally generated keys instead of panicking by @gouguolei in 012269d
- test(keypair): cover error paths and key material helpers by @gouguolei in 12c3e11
- docs(readme): replace old badge with golangci-lint by @gouguolei in 0517244
- docs(readme): replace old badge with golangci-lint by @gouguolei in 1487675
- test: Clean up redundant content and unused variables in the test code by @gouguolei in 372209d
- test(sm2): DER encoding error branch covering key formatting by @gouguolei in 6ad47b4
- refactor(keypair): Extract x509 Marshall function as a variable to support testing simulation by @gouguolei in e314c99
- refactor(crypto): Replace the ed25519 key serialization function with a local implementation by @gouguolei in 0769ea0
- refactor(rsa): Replace the standard library key serialization function with a custom implementation by @gouguolei in 2c9ad5a
- refactor(crypto/rsa): Simplify function signatures and clean up redundant code by @gouguolei in 68dad92
- docs(readme): Replace the golangci lit badge with the GitHub Actions status badge by @gouguolei in e6f8039
- docs(readme): Replace the image resource reference from remote URL to local assets path by @gouguolei in 19bffd5
v1.2.3 (2025-12-16)
✨ 新功能
- RSA 密钥对可以只持有当前操作需要的那把密钥:
RsaKeyPair新增Type字段并配套SetType方法,同时新增KeyType类型及其PublicKey、PrivateKey常量;NewStdEncrypter、NewStdDecrypter、NewStdSigner、NewStdVerifier与对应的流式实现按密钥类型分派,只持有公钥的密钥对可以加密、验签,只持有私钥的密钥对可以解密、签名,公钥同样可以作为签名方、由私钥验证;Type为空时按操作自动回退——加密与验签使用PublicKey,解密与签名使用PrivateKey;默认填充跟随密钥格式,PKCS1使用PKCS1v15,PKCS8加密使用OAEP、签名使用PSS,签名传入OAEP或加密传入PSS会返回UnsupportedPaddingSchemeError;crypto/internal/rsa补齐了公钥与私钥两种方向、每种填充组合的实现,包括 Go 标准库只提供单向接口的 PSS 编码与 MGF1(by @gouguoyin in 12ffe48 eb81cbc 33ac684 749b690) Sm2KeyPair新增SetMode方法,CipherOrder重命名为Sm2CipherMode:SetMode成为选择密文顺序的推荐写法,SetOrder保留为薄封装以保证已有调用仍可编译;类型重命名只影响显式写出CipherOrder的代码,参数名order统一改为mode,不再与密钥顺序的含义混淆(by @gouguoyin in 858d8b8 3785a02 6d30805 56b6b15)
🔧 重构
- 移除
Sm2KeyPair的LoadPublicKey、LoadPrivateKey方法:SM2 此前是唯一由密钥对自己读取文件的实现,调用方必须传入fs.File;现在改为自行读取文件后调用SetPublicKey/SetPrivateKey,与 RSA、Ed25519 保持一致(by @gouguoyin in e4d6e3c) - 将
crypto/sm2拆分为encrypt.go、decrypt.go、sign.go、verify.go,内部辅助函数重命名为EncryptWithPublicKey、DecryptWithPrivateKey、SignWithPrivateKey、VerifyWithPublicKey,函数需要哪把密钥在调用处一眼可见;同时删除冗余的 SM2 实现、把辅助函数拆到独立文件,priv字段更名为pri以与包内其他命名一致(by @gouguoyin in 86819de 1602745 0dfd8ea c0a45e4 ccc968f f876923) - 缓存 Ed25519 解析后的密钥:签名器与验签器此前每次调用都要解析一次 PEM,并与
crypto/keypair中已有的解析逻辑重复;现在两者只解析一次并缓存结果,重复代码被删除,包内文件拆分为ed25519.go、sign.go、verify.go(by @gouguoyin in 0ed7ca5) - 删除 RC4 回退分支中冗余的 cipher 创建:该分支创建的 cipher 立即被丢弃(by @gouguoyin in 9320875)
What's Changed (18)
- refactor(ed25519): Remove duplicate key parsing logic and use caching to improve performance by @gouguoyin in 0ed7ca5
- refactor(rc4): Delete the redundant code for creating cipher in fallback by @gouguoyin in 9320875
- chore(sm2): Remove redundant implementation and modularize the splitting function to independent files by @gouguoyin in 86819de
- refactor(sm2): priv -> pri by @gouguoyin in f876923
- feat(rsa): Provide signature generation and verification methods based on public and private keys by @gouguoyin in 749b690
- feat(keypair): Add key type definition to distinguish between public and private keys by @gouguoyin in 12ffe48
- feat(rsa): Add a Type field in the RsaKeyPair structure to specify the key type by @gouguoyin in eb81cbc
- feat(rsa): Add support for public key encryption and private key decryption by @gouguoyin in 33ac684
- refactor(sm2): Remove the CipherOrder type definition and replace it with a string constant by @gouguoyin in 3785a02
- refactor(sm2): Delete the 'LoadPublicKey' and 'LoadPrivateKey' methods by @gouguoyin in e4d6e3c
- refactor(sm2): Decrypt -> DecryptWithPrivateKey by @gouguoyin in 1602745
- refactor(sm2): Encrypt -> EncryptWithPublicKey by @gouguoyin in 0dfd8ea
- refactor(sm2): Sign -> SignWithPrivateKey by @gouguoyin in c0a45e4
- refactor(sm2): Verify -> VerifyWithPublicKey by @gouguoyin in ccc968f
- refactor(sm2): Change the function parameter name from 'order' to 'mode' by @gouguoyin in 6d30805
- feat(crypto): Add
SetModemethod to replace the existingSetOrdermethod by @gouguoyin in 858d8b8 - refactor(sm2): Rename the Order parameter to Mode by @gouguoyin in 56b6b15
- docs(utils): Update Int2Bytes function comments by @gouguoyin in 3d22896
v1.2.2 (2025-12-08)
✨ 新功能
- 为链式 API 增加 SM2 签名与验签能力:新增
Signer.BySm2与Verifier.BySm2,标准处理和流式处理均支持,SM2 与 RSA、Ed25519 一样可以在同一条链上用私钥签名、用公钥验签;Sm2KeyPair.SetUID用于设置参与 ZA 计算的用户标识,未设置时保持1234567812345678;验签时签名为空会在进入曲线运算前直接返回EmptySignatureError(by @gouguoyin in b72066e 0382cd6 39d00c3) - 增加 RSA 填充方案选择:新增
RsaPaddingScheme类型,提供PKCS1v15、OAEP、PSS三种填充,通过SetPadding指定;PKCS1v15可用于加密与签名,OAEP仅用于加密且需要通过SetHash指定哈希,PSS仅用于签名;未显式设置时按密钥格式回退,PKCS1密钥使用PKCS1v15、PKCS8密钥使用OAEP,不支持的组合返回UnsupportedPaddingSchemeError而不是标准库的笼统错误(by @gouguoyin in d1734dc b4173be d08e5fc) - 新增一组细分的密钥与签名错误类型:
EmptyPrivateKeyError、EmptyFormatError、UnsupportedKeyFormatError、EmptyPaddingError、UnsupportedPaddingSchemeError、EmptySignatureError取代原先的笼统错误,调用方可以区分「密钥为空」和「密钥格式错误」(by @gouguoyin in 856dd51)
🐛 修复
- 修复私钥为 PKCS#8 格式时无法解密 PKCS#1 v1.5 密文的问题(#39):当
Format为PKCS8且未显式设置填充时,解密默认走 OAEP,导致 JSEncrypt 或 PHPopenssl_*默认填充产生的密文报crypto/rsa: decryption error,而同样的密文 PHP 自己却能解开;现在可通过SetPadding指定填充,报告中使用的密钥对也保留为回归测试(by @gouguoyin in 27c69f6) - 移除 RSA 验签中冗余的签名长度检查:该检查会在
rsa.Verify*校验之前就把其他库生成的合法签名拒掉,而标准库本身对长度错误的签名已有明确报错(by @gouguoyin in faa99bb)
⚡ 性能优化
- 摩斯编码、解码返回结果时少一次拷贝:
[]byte(builder.String())改为utils.String2Bytes,直接复用builder的缓冲区而不再多复制一份,对输出本身已是大头的场景收益明显(by @gouguoyin in 10d2eb0)
🔧 重构
- 按算法重命名密钥格式与密文顺序类型:
KeyFormat改为RsaKeyFormat,CipherOrder改为Sm2CipherOrder,不再使用看起来像对所有算法都生效的通用名;NoSignatureError改为EmptySignatureError,UnsupportedPemTypeError改为UnsupportedKeyFormatError,Ed25519KeyPair.Sign改为Signature(by @gouguoyin in 37d5a1a ac77cf7 6135756 8a6ea39) - 重写 RSA 加解密与签名验签逻辑:每种操作在创建加密器、解密器、签名器、验签器时一次性确定填充方案并按方案分派,
PSS被用于加密、OAEP缺少哈希等情况在构造时就会报错,而不是在流处理中途失败(by @gouguoyin in d08e5fc) - 重命名各流式解密器的字段:
decrypted改为buffer、pos改为position,覆盖 3DES、AES、Blowfish、DES、Tea、XTea、Twofish、SM4 与 Salsa20,同时简化 3DES 流式解密的数据切分逻辑(by @gouguoyin in 114d3be efefe59 e66e508 ba303e7 4d93579 e0b9f3b 5f311b4 426506a f375496 ce101f1) - Ed25519 的
StdSigner、StdVerifier改为按值持有密钥对:不再持有指针,构造之后外部修改密钥对不会影响正在进行的操作,同时简化 Ed25519 的错误类型(by @gouguoyin in b5cd502 225b70f) - 将
mock、utils移入internal:测试辅助包与零拷贝辅助函数不再对外暴露,SM4 实现同时迁入crypto/internal/sm4(by @gouguoyin in ef82486 fe841a7) - 内部
sm2curve包重命名为sm2,并把stdAsn1别名统一为其他文件使用的encodingAsn1(by @gouguoyin in 14e9818 cf69603) - 简化测试:用
internal/mock的mock.File取代各测试中重复实现的 reader mock,所有测试文件补上打开文件的关闭操作,中文注释统一改为英文(by @gouguoyin in 6b021d7 3ea3710 bd8b1b3 7fb2ddc 9a4b693 2cab5e7 bbc4123 ee77460)
📝 文档
- 更新密钥对包文档与 RSA 使用说明,补充新的填充方案与密钥格式类型(by @gouguoyin in dafc7cf b765056 399de93)
What's Changed (38)
- refactor(sm2curve): ParseDerPublicKey -> ParseBitStringPublicKey, ParseDerPrivateKey -> ParseBitStringPrivateKey by @gouguoyin in faac61c 81224c4
- refactor(internal): Move
mockandutilspackages tointernalby @gouguoyin in ef82486 - refactor(sm2curve): stdAsn1 -> encodingAsn1 by @gouguoyin in cf69603
- docs: Remove document comments for package by @gouguoyin in 43a793b
- test(coding): Change Chinese annotations to English by @gouguoyin in ee77460
- refactor(crypto/3des): Optimize the data processing logic of the streaming decryptor by @gouguoyin in ce101f1
- refactor: decrypted -> buffer, pos -> position in AES, Blowfish, DES, Tea, XTea, Twofish, SM4 and Salsa20 by @gouguoyin in 114d3be efefe59 e66e508 ba303e7 4d93579 e0b9f3b 5f311b4 426506a f375496
- refactor(ed25519): Modify the keypair field in StdSigner and StdVerifier to a value type instead of a pointer type by @gouguoyin in b5cd502
- refactor(ed25519): Simplify error types and optimize error message formats by @gouguoyin in 225b70f
- chore(crypto): NoSignatureError -> EmptySignatureError by @gouguoyin in 6135756
- fix(rsa): Remove redundant signature length check by @gouguoyin in faa99bb
- fix(rsa): Fix PKCS8 format key decryption failure (issue #39) by @gouguoyin in 27c69f6
- refactor(crypto): Sign -> Signature, UnsupportedPemTypeError -> UnsupportedKeyFormatError by @gouguoyin in 8a6ea39
- feat(crypto): Add multiple types of key and signature related errors by @gouguoyin in 856dd51
- feat(crypto): Introduce PaddingScheme type to support multiple RSA filling schemes by @gouguoyin in d1734dc
- feat(rsa): Add the SetPadding method by @gouguoyin in b4173be
- refactor(rsa): Refactoring RSA encryption, decryption, signature verification logic by @gouguoyin in d08e5fc
- feat(sm2curve): Implement SM2 algorithm signature and verification function by @gouguoyin in 0382cd6
- feat(sm2): Add SetUID method by @gouguoyin in 39d00c3
- refactor(crypto/sm2): Remove unused error types by @gouguoyin in 7bc33cd
- feat(crypto): Add SM2 signature and verification function by @gouguoyin in b72066e
- refactor(sm2): Remove redundant auxiliary functions and dependencies by @gouguoyin in bc5962c
- docs(keypair): Update the documentation for the key pair package by @gouguoyin in dafc7cf
- chore(rsa): Move the RSA key format and padding scheme type to the
rsa.gofile by @gouguoyin in 88ba1d6 - chore(sm2): Move the SM2 cipher order from
keypair.gotosm2.gofile by @gouguoyin in ac77cf7 - chore(test): KeyFormat -> RsaKeyFormat by @gouguoyin in 37d5a1a
- refactor(sm2): Rename the sm2curve package to sm2 and update related references by @gouguoyin in 14e9818
- refactor: Modify the cipher field type of the encryption and decryption structures in 3DES, AES, Blowfish, ChaCha20, ChaCha20-Poly1305, DES, Salsa20, Tea, XTea, Twofish and SM4 by @gouguoyin in d7d72be af560ef 582d5d8 38587f9 5b780d4 4c87f81 b0f2e45 ec29312 8435966 1b2be97 ab4ee6d
- test(sm2): []byte{} -> {} by @gouguoyin in 48834cc
- refactor(sm4): Migration of SM4 implementation from crypto/sm4/core.go to crypto/internal/sm4/sm4.go by @gouguoyin in fe841a7
- refactor(morse): Optimize the conversion method from string to byte slice by @gouguoyin in 10d2eb0
- test(coding): Simplify code using mock.File by @gouguoyin in 6b021d7
- test(crypto): Simplify code using mock.File by @gouguoyin in 3ea3710
- test(hash): Simplify code using mock.File by @gouguoyin in bd8b1b3
- test(sm2): Simplify code using mock.File by @gouguoyin in 7fb2ddc
- test: Add defer file.Close() to all test functions to avoid resource leakage by @gouguoyin in 9a4b693 2cab5e7 bbc4123
- docs(crypto): Update RSA key pair document comments by @gouguoyin in b765056
- docs(rsa): Update RSA key pair usage instructions by @gouguoyin in 399de93
v1.2.1 (2025-11-24)
✨ 新功能
- 增加
Sm2非对称椭圆曲线加密算法对BIT_STRING格式密钥直接解析支持
🐛 修复
- 修复
Sm2非对称椭圆曲线加密算法中wNAF算法错误造成某些情况下解密失败的bug
⚡ 性能优化
- 优化
Sm2非对称椭圆曲线加密算法中曲线域元素运算实现
🔧 重构
- 简化测试循环语法,从
for循环改为range循环
What's Changed (12)
- refactor(sm2curve): pointFelem -> pointField by @gouguoyin in eb6878e
- test(sm2): Change the declaration method of empty byte slices from literal to var declaration by @gouguoyin in 38a86c8
- style(sm2curve): Add necessary comments by @gouguoyin in 27497c7
- Potential fix for code scanning alert no. 1: Workflow does not contain permissions (#33) by kuafuRace in 9bab6c9
- Add direct parsing of hexadecimal key pairs for SM2 (#32) by @WebChang in a4509b6
- Fix the wNAF algorithm (#36) by @WebChang in 73911e8
- fix(crypto): Introduce a rewritable parseDerPrivatKeyFunc variable to support test simulation by @gouguoyin in d61fe04
- test(sm2): Improve unit testing coverage to 100% by @gouguoyin in 7b2ddf3
- chore(version): Update version number to 1.2.1 by @gouguoyin in 31d1ee7
- Add issue unit test (#38) by @WebChang in b91161c
- fix(sm2curve): Fix SM2 curve domain element subtraction and borrowing processing by @gouguoyin in 1164b55
- fix(sm2): Add issue #34 unit test by @gouguoyin in b86b4dd
v1.2.0 (2025-11-11)
✨ 新功能
RSAKeyPair结构体增加FormatPublicKey和FormatPrivateKey方法,用于将base64编码的der格式的RSA公钥和私钥格式化成pem格式Ed25519KeyPair结构体增加FormatPublicKey和FormatPrivateKey方法,用于将base64编码的der格式的Ed25519公钥和私钥格式化成pem格式RSAKeyPair结构体增加CompressPublicKey和CompressPrivateKey方法,用于将pem格式的RSA公钥和私钥压缩成经过base64编码的der格式Ed25519KeyPair结构体增加CompressPublicKey和CompressPrivateKey方法,用于将pem格式的Ed25519公钥和私钥压缩成经过base64编码的der格式- 增加
Sm2非对称椭圆曲线加密算法支持,包括标准处理和流式处理
⚡ 性能优化
- 优化编码器和解码器性能,重用读缓冲区,减少内存分配和复制
🔧 重构
- 移除
RSAKeyPair结构体的LoadPublicKey和LoadPrivateKey方法 - 移除
Ed25519KeyPair结构体的LoadPublicKey和LoadPrivateKey方法 RSAKeyPair结构体的GenKeyPair,SetPublicKey,SetPrivateKey方法从无返回值改为返回errorEd25519KeyPair结构体的GenKeyPair,SetPublicKey,SetPrivateKey方法从无返回值改为返回error
What's Changed (25)
- chore(dongle): Update package meta and version number by @gouguoyin in ab46cdb
- feat(mock): Add
Error WriteAfterNstruct, which supports returning an error after a specified number of writes by @gouguoyin in a92350f - test(style): Unify unit test case Name by @gouguoyin in fda8e09
- fix(cipher): Change the return value of empty input from
srcto[]byte{}by @gouguoyin in 81d8e29 - feat(sm2curve): Implement SM2-P-256 elliptic curve and ASN.1 encoding and decoding for sm2 by @gouguoyin in 8120c6b
- perf(base32): Optimize the performance of streaming codecs by @gouguoyin in df8bc9f
- perf(base45):Optimize the performance of base45 encoding and decoding by @gouguoyin in 15669d5
- refactor(base58): Optimize the implementation of stream encoders and decoders by @gouguoyin in 70b7b7b
- refactor(base62): Optimize the implementation of stream encoders and decoders by @gouguoyin in 2de952d
- perf(base64): Optimize the implementation of stream encoders and decoders by @gouguoyin in 94575a1
- refactor(base85): Optimize the implementation of stream encoders and decoders by @gouguoyin in 5c03d1a
- perf(base91): Optimize encoding and decoding performance by @gouguoyin in bcff90c
- perf(base100): Optimize the implementation of stream encoders and decoders by @gouguoyin in 058877c
- refactor(morse): Optimize the buffer usage of streaming decoders by @gouguoyin in a52a536
- feat(unicode): Optimize the buffer usage of streaming decoders by @gouguoyin in dd27319
- feat(crypto): Add FormatPublicKey,FormatPrivateKey, CompressPublicKey, CompressPrivateKey methods by @gouguoyin in e947625
- feat(crypto): Add EmptyPublicKeyError and EmptyPrivateKeyError by @gouguoyin in c844db5
- refactor(keypair): Add CipherOrder type to control the order of SM2 ciphertext components by @gouguoyin in e3d8df9
- feat(sm2): Add support for SM2 asymmetric elliptic curve encryption algorithm by @gouguoyin in dfa2a45
- perf(md2): Optimize the performance of MD2 hash algorithm by @gouguoyin in 380718a
- perf(sm3): Optimize the performance of SM3 hash algorithm by @gouguoyin in 9b1e3ed
- docs(readme): Add playground link url by @gouguoyin in c4fac75
- docs: Update the annotation explanation in AES symmetric encryption algorithm by @gouguoyin in 4adf429
- refactor(sm2curve): Refactor the SM2 curve implementation to improve performance and maintainability by @gouguoyin in 10eefe2
- refactor(crypto): MarshalPKCS8 -> MarshalPKCS8PrivateKey, MarshalSPKI ->MarshalSPKIPublicKey by @gouguoyin in ef63d93
v1.1.8 (2025-11-05)
✨ 新功能
- 增加
Unicode编码解码支持,包括标准处理和流式处理 - 对称分组加密算法增加
TBC填充模式支持
🐛 修复
- 修复
*RsaKeyPair.formatPublicKey和*RsaKeyPair.formatPrivateKey格式化密钥失败的 bug - 修复
*Ed25519KeyPair.formatPublicKey和*Ed25519KeyPair.formatPrivateKey格式化密钥失败的 bug - 修复解密时对编码过的密文解码失败后无法获取错误的 bug
🔧 重构
- 对称分组加密算法中默认填充模式从
PKCS7改为No
What's Changed (36)
- chore(version): Update version number to
1.1.8by @gouguoyin in 3bfd036 - feat(crypto): Add TBC padding mode support by @gouguoyin in 304629d
- feat(unicode): Add
Unicodeencoding and decoding support by @gouguoyin in d174cd8 - ci(test): Add support for Windows testing environment by @gouguoyin in da9ec1e
- fix(hash): Add checks for h.Error by @gouguoyin in c044908
- fix(decoder): Add checks for d.Error by @gouguoyin in 18041a3
- fix(encoder): Add checks for e.Error by @gouguoyin in f97a481
- feat(unicode): Add
Unicodeencoding/decoding support by @gouguoyin in 8e1c38c - feat(crypto): Add custom nonce length support for
GCMmode by @gouguoyin in 5cdaac8 - fix(signer): Add checks for s.Error by @gouguoyin in f0f2bc2
- fix(crypto): Fix signature decoding error handling by @gouguoyin in 4107901
- fix(crypto): Fix ciphertext decoding error handling by @gouguoyin in 763afd8
- refactor(crypto): Change the default padding mode from
PKCS7toNoby @gouguoyin in 00bd32b - feat(crypto/cipher): Optimize the block size check in CBC mode by @gouguoyin in 781f292
- refactor(cipher): Simplify the error handling using switch by @gouguoyin in a0abcf5
- refactor(cipher): InvalidSrcError -> InvalidPlaintextError by @gouguoyin in 2677ffc
- test(des): Remove redundant decryption error test cases by @gouguoyin in 72c39cd
- test(aes): Remove redundant decryption error test cases by @gouguoyin in 36807d5
- test(sm4): Remove padding settings by @gouguoyin in 7cdf2b5
- feat(crypto): Remove padding setting by @gouguoyin in bac1c2a
- fix(xtea): Fix the panic issue in the stream encryption by @gouguoyin in 94596c4
- test(crypto): Update error type assertion by @gouguoyin in 15014ea
- fix(aes): Remove unnecessary comments by @gouguoyin in 37d2aeb
- fix(crypto): Update 3DES decryption error type assertion by @gouguoyin in 1d6ff35
- feat(crypto): Add empty source data check by @gouguoyin in ba919b3
- feat(crypto): Add EmptySrcError type by @gouguoyin in 3dd14a4
- refactor(ed25519): Refactor key formatting method and adding compression method by @gouguoyin in 5be56c1
- refactor(rsa): Refactor RSA key formatting method and adding compression method by @gouguoyin in 7fcd12c
- feat(keypair): Add formatKeyBody function by @gouguoyin in 0893b5d
- refactor(ed25519): Remove non essential comments by @gouguoyin in 734a5f2
- test(ed25519): Add edge testing for
StreamSigner.Writemethod by @gouguoyin in db4dd67 - refactor(crypto): Delete the Error field and instead handle errors through return values by @gouguoyin in b5d9349
- refactor(rsa): Change the return value of the
GenKeyPairmethod from*RsaKeyPairto error by @gouguoyin in e384f4f - chore(crypto): Simplify code by @gouguoyin in 40e077a
- chore(ed25519): Improve key generation and parsing error handling by @gouguoyin in 20893dc
- chore(rsa): Improve key generation and parsing error handling by @gouguoyin in ab5e7a8
v1.1.7 (2025-10-20)
✨ 新功能
- 增加
sm4中国国家标准分组加密算法支持,包括标准处理和流式处理,支持不同分块模式和填充模式
🐛 修复
- 修复非对称数字签名算法中验签错误的 bug #30
- 优化流式处理逻辑,添加对
reader位置重置的支持,确保从数据源的开头开始读取,避免因之前读取操作导致的位置偏移问题,保证流式操作的完整性和正确性
🔧 重构
crypto/cipher/block.go中newXXXEncrypter和newXXXDecrypter系列私有方法更改成公开方法NewXXXEncrypter和NewXXXDecryptercrypto/cipher/padding.go中newXXXPadding和newXXXUnPadding系列私有方法更改成公开方法NewXXXPadding和NewXXXUnPadding
What's Changed (38)
- chore: Add support for the
io.Seekerinterface to reset the reading position by @gouguoyin in 07a19a9 - refactor(decoder): ff -> f by @gouguoyin in ae38f87
- refactor(test): Unify package import order by @gouguoyin in 36064e0
- docs(github/crypto): Add a period to the note on the encryption method by @gouguoyin in c4af6bd
- feat(crypto): Add support for the SM4 block cipher algorithm by @gouguoyin in 537b615
- chore(crypto/cipher): Remove the comment regarding the default number of rounds in TEA encryption by @gouguoyin in 8b72470
- feat(cipher): Unify function naming convention, newXXX -> NewXXX by @gouguoyin in cff507c
- build(dongle): Update the version number to v1.1.7 by @gouguoyin in 22f0f85
- docs(crypto/cipher): Update the annotation of the padding function by @gouguoyin in f90f6a7
- chore(crypto/cipher): Unify error return variable names and remove redundant comments by @gouguoyin in 6e9db0f
- fix(coding): Optimize the return value when there is an error by @gouguoyin in b581d3b
- chore(crypto): Add initialization error checking by @gouguoyin in 01d6ec7
- test(aes): Delete unnecessary test cases by @gouguoyin in af904d0
- test(des): Delete unnecessary test cases by @gouguoyin in b3f67f6
- test(xtea): Delete unnecessary test cases by @gouguoyin in ba26567
- fix(cipher): Remove duplicate nil block checking logic by @gouguoyin in f13aa33
- chore(crypto/cipher): Add CBC/ECB mode padding processing comments by @gouguoyin in 1205cab
- chore(crypto/cipher): Remove the early return logic when the extra data is empty by @gouguoyin in b66ba65
- test(cipher): Remove duplicate decryption test cases by @gouguoyin in b534394
- test(crypto): Remove test case for invalid cipher by @gouguoyin in d5b5849
- chore(coding): Add comments to Encoder and Decoder structures by @gouguoyin in 57ae7a4
- refactor(crypto):
UnsupportedModeError->UnsupportedBlockModeErrorby @gouguoyin in b6e71b1 - docs(hash): Update package comments by @gouguoyin in 3eb6ce7
- docs(cipher): Add comments by @gouguoyin in 4ec008c
- refactor(cipher): Remove unnecessary return parameters by @gouguoyin in 4e52d83
- fix(cipher): Improve encryption and decryption error handling logic by @gouguoyin in 0d5947a
- feat(crypto): Add UnsupportedBlockModeError and UnsupportedPaddingModeError by @gouguoyin in 2cc0511
- feat(cipher): Optimize zero padding logic by @gouguoyin in cbb4c56
- docs(keypair): Add comments by @gouguoyin in 2122e07
- docs: Update the description of padding mode and hash algorithms in the README by @gouguoyin in 3d0dbb7
- refactor(cipher): Refactor the padding and unpadding methods as receiver methods by @gouguoyin in 3d73c89
- chore(hash): Add comments by @gouguoyin in fe9ba67
- chore(cipher): Unified error return format by @gouguoyin in 063b25c
- fix(rsa): Fix variable reference errors in signature verification logic,
kp.Sign->v.signby @gouguoyin in e78cd47 - test: Add issue #30 unit test cases by @gouguoyin in 2cb142a
- feat(crypto): Add verify status field to enhance signature verification logic by @gouguoyin in c7a76bd
- refactor(utils): []byte("") -> []byte{} by @gouguoyin in 7e378cd
- vm-os: [ubuntu-latest, macos-latest, windows-latest] by kuafuRace in 340283c
v1.1.6 (2025-10-12)
✨ 新功能
- 优化
tea加密算法,支持不同分块模式和填充模式 - 增加
xtea加密算法支持,包括标准处理和流式处理
🔧 重构
- 使用
io.CopyBuffer简化流式处理逻辑
What's Changed (26)
- docs(readme): Update the import path in README.cn.md by @gouguoyin in dbe8da4
- refactor: Rename the
utilpackage toutilsby @gouguoyin in 9c4122e - refactor(cipher): decrypted -> paddedDst by @gouguoyin in 4537c96
- refactor(mock): Unify the naming of receivers in error file simulation by @gouguoyin in def9c0a
- refactor(mock): Move package comment from
file.gotodoc.goby @gouguoyin in 0a86b4a - refactor(utils): Add package comment in
doc.goby @gouguoyin in d625676 - style: Add necessary notes by @gouguoyin in 35ed473
- docs: Add package comments by @gouguoyin in 08ddc95
- chore(encoder):Optimize error handling logic by @gouguoyin in 6b723b5
- chore(coding): Unify the naming of error handling variables and optimize the reading logic by @gouguoyin in 3d16e0f
- chore(crypto): Unify the naming of error handling variables and optimize the reading logic by @gouguoyin in ca35d52
- test: Add test case for issue #28 by @gouguoyin in b87981c
- build: Update version number to
1.1.6by @gouguoyin in 4a16814 - refactor(hash): Use
io.CopyBufferto replace manual reading of the buffer, simplifying the implementation ofstreamandhmacmethods by @gouguoyin in cf399b5 - fix(blowfish): Fix the return value counting logic after encrypted data is written by @gouguoyin in 70ea1f7
- refactor(ed25519): Remove redundant random number generator by @gouguoyin in 6c974f4
- fix(rsa): Optimize RSA key parsing logic and fix return value handling by @gouguoyin in 6ca625c
- feat(crypto): Use
io.CopyBufferto improve the performance and efficiency of stream processing readability and fixing potential read error issues by @gouguoyin in b1d4247 - refactor(decoder):Simplify streaming process with
io.CopyBufferby @gouguoyin in bc1c6ab - refactor(encoder):Simplify streaming process with
io.CopyBufferby @gouguoyin in 730c151 - feat(crypto/tea): Optimize the tea algorithm to support different blocking and padding modes by @gouguoyin in 817e4c5
- feat(crypto/xtea): Add support for
xteaalgorithm by @gouguoyin in 6cc0c01 - test(3des): Remove useless and erroneous tests by @gouguoyin in 2df56d8
- test: Replace the existing custom errorCloser with CloseErrorWriteCloser from the mock library by @gouguoyin in e70157b
- feat(cipher): Update the implementation of the TEA encryption algorithm to support block mode by @gouguoyin in b90d008
- style: Unify the function annotation style and revise some algorithm descriptions by @gouguoyin in 9509d43
v1.1.5 (2025-10-01)
🐛 修复
- 修复对称加密算法中对不需要填充的分组模式(如 CFB/OFB/CTR/GCM 等)进行填充时加解密错误的bug
What's Changed (6)
- build(dongle): Updated version number to 1.1.5 by @gouguoyin in 8e1a462
- test(issue): Add issue test file by @gouguoyin in d77ad8c
- refactor(crypto): Unify package grouping import rule by @gouguoyin in 17ff89c
- test(aes): Remove t.Skip test cases by @gouguoyin in 82f450f
- refactor(coding): Unify package grouping import rule by @gouguoyin in 833c1c2
- refactor(cipher): Optimize the logical structure of encryption and decryption #29 by @gouguoyin in a598772
v1.1.4 (2025-09-23)
✨ 新功能
- 增加
twofish加密算法支持,包括标准处理和流式处理
🔧 重构
- 将方法接受者从指针改成值,防止出现使用全局默认实例时属性污染现象,调用方
API没有任何影响
What's Changed (5)
- build(dongle.go): Update the version number to v1.1.4 by @gouguoyin in 3abadc6
- refactor: Change the receiver of the method from a pointer type to a value type by @gouguoyin in 9b9b104
- docs(chacha20): Add package comments``` by @gouguoyin in 3a66727
- docs(chacha20poly1305): Add package comments by @gouguoyin in 25b9c56
- feat(crypto): Add support for the Twofish encryption algorithm by @gouguoyin in fd78849
v1.1.3 (2025-09-15)
✨ 新功能
- 更新
testify依赖至v1.11.1
🐛 修复
- 优化
3DES对称加密算法对16字节密钥的兼容 - 优化
DES对称加密算法对不支持的GCM模式的校验 - 优化
3DES对称加密算法对不支持的GCM模式的校验 - 优化
Blowfish对称加密算法对不支持的GCM模式的校验
🔧 重构
- 增加
Salsa20加密算法支持,包括标准处理和流式处理
What's Changed (21)
- chore(deps): Update the testify dependency to
v1.11.1by @gouguoyin in 6644d40 - chore: Update dongle to
v1.1.3by @gouguoyin in efa7ffd - perf(hash/md2): []byte{} -> var data []byte by @gouguoyin in e4c4362
- refactor(hash): Unify import package order by @gouguoyin in 57a68fa
- perf(test): []byte{} -> var data []byte by @gouguoyin in f2c7321
- feat(crypto): Add support for the Salsa20 encryption algorithm by @gouguoyin in 8df1550
- fix(crypto/des): Add a error check for unsupported
GCMmode by @gouguoyin in 10c123d - fix(crypto/blowfish): Add an error check for unsupported
GCMmode by @gouguoyin in 7f343cb - fix(crypto/3des): Add an error check for unsupported
GCMmode by @gouguoyin in 6c12f0c - fix(crypto/des): Add an error check for unsupported
GCMmode by @gouguoyin in 895547e - refactor(crypto/aes): Optimize AES encryption and decryption operations by @gouguoyin in 436ae5e
- test(3des): Create alone test files for each block cipher mode by @gouguoyin in ae47981
- test(aes): Create alone test files for each block cipher mode by @gouguoyin in 4c1c349
- test(blowfish): Create alone test files for each block cipher mode by @gouguoyin in 31cfeab
- test(des): Create alone test files for each block cipher mode by @gouguoyin in 171eb70
- fix(crypto/chacha20): Unify import package order by @gouguoyin in d8c9242
- chore(crypto/chacha20loly1305): Unify import package order by @gouguoyin in 718779f
- test(rc4): Modify the test case description by @gouguoyin in f3cad2b
- test(crypto): Unify import package order by @gouguoyin in 8a8361a
- perf(benchmarks): init -> initBenchData by @gouguoyin in 88e5a2f
- feat(crypto): Add documentation comments for the package by @gouguoyin in 9fbddeb
v1.1.2 (2025-09-08)
✨ 新功能
- 编码/解码支持通过
coding.BufferSize全局变量自定义文件流缓冲区大小 - 加密/解密支持通过
crypto.BufferSize全局变量自定义文件流缓冲区大小 - Hash/Hmac 算法支持通过
hash.BufferSize全局变量自定义文件流缓冲区大小 - 增加
Blake2b哈希算法支持,包括blake2b-256、blake2b-384和blake2b-512 - 增加
Blake2s哈希算法支持,包括blake2s-128和blake2s-256 - 增加
ChaCha20加密算法支持 - 增加
ChaCha20Poly1305加密算法支持
What's Changed (24)
- fix(crypto): Remove redundant code by @gouguoyin in 05ec861
- feat(crypto): Add support for the
ChaCha20encryption algorithm by @gouguoyin in cdff998 - docs: Update usage examples by @gouguoyin in 6710e8f
- refactor(coding): Add BufferSize global variable to define the buffer size for stream processing by @gouguoyin in 2fecf80
- refactor(hash): Add BufferSize global variable to define the buffer size for stream processing by @gouguoyin in 870c557
- refactor(crypto): Add BufferSize global variable to define the buffer size for stream processing by @gouguoyin in 768d89d
- refactor(hash): hash -> hashFunc by @gouguoyin in f68a56c
- refactor(hash): Optimize error messages by @gouguoyin in 1d4d33b
- docs(README): Add digital signature and verification example by @gouguoyin in 762ba1c
- docs: Remove the digital signature and verification example by @gouguoyin in 2eeccf2
- docs(README): Update RSA signature verification example by @gouguoyin in 49e802b
- refactor(hash): Remove the redundant variable totalBytes by @gouguoyin in e14030d
- feat(hash): Add support for the
BLAKE2bhash algorithm by @gouguoyin in 0683cc0 - feat(hash): Add support for the
BLAKE2shash algorithm by @gouguoyin in f5870d7 - test(hash): Unified import of grouping styles by @gouguoyin in 74c2c4a
- test(coding): Unified import of grouping styles by @gouguoyin in 6bb8efd
- test(crypto): Unified import of grouping styles by @gouguoyin in 63e3e81
- test(keypair): Unified import of grouping styles by @gouguoyin in 72be367
- test(cipher): Unified import of grouping styles by @gouguoyin in 6961d3f
- test(cipher): blockCipher.Aad -> blockCipher.AAD by @gouguoyin in 04848cc
- feat(crypto): Add support for
ChaCha20-Poly1305encryption algorithm by @gouguoyin in 8e3b5c3 - docs(README):
hex string->hex-encoded string,base64 string->base64-encoded stringby @gouguoyin in 2c78e49 - docs(README): Use the import block to uniformly import multiple packages by @gouguoyin in 7d8e358
- build: Update the version number to 1.1.2 by @gouguoyin in 80b23e0
v1.1.1 (2025-09-01)
✨ 新功能
- 编码/解码、加密/解密、Hash/Hmac、签名/验签支持真正的流式处理
- 增加
ED25519数字签名和验证支持 - 增加
SM3哈希算法支持 coding/morse/morse.go增加对空格、标点符号和特殊字符的支持
⚡ 性能优化
- 当输入数据为空时,直接返回空数据而不执行后续操作
🔧 重构
- 对称加密算法从
ByXXX(cipher.XXXCipher)改成ByXXX(*cipher.XXXCipher) - 将工具包名从
utils改成util - 增加
mock/hash.go来模拟hash.Hash接口的错误
What's Changed (42)
- docs(readme): Update RSA encryption and decryption example by @gouguoyin in 4094aac
- refactor: Rename utils package to util by @gouguoyin in 9242991
- feat(hash): Add support for
SM3hash algorithm by @gouguoyin in 3f6e407 - refactor(crypto/3des): Refactor 3DES encryptor and decryptor by @gouguoyin in 4ed070e
- refactor(crypto): Refactor AES encryptor and decryptor by @gouguoyin in 6a3dcf9
- refactor(crypto): Refactor DES encryptor and decryptor by @gouguoyin in 39193c7
- refactor(rc4): Change the parameter type of the ByRc4 method from
cipher.Rc4Cipherto*cipher.Rc4Cipherby @gouguoyin in 4bcba4e - refactor(tea):
cipher.TeaCipher->*cipher.TeaCipherby @gouguoyin in f90f82c - refactor(tea):
cipher.BlowfishCipher->*cipher.BlowfishCipherby @gouguoyin in af4db9d - refactor(crypto/cipher):Rename the
paddingfunction and remove the internaldispatcherby @gouguoyin in e44f321 - feat(crypto): Add the blockCipher struct and encryption/decryption functionality by @gouguoyin in 0c93355
- refactor(crypto/cipher): Change the encryptor and decryptor methods to private by @gouguoyin in 4ab52bd
- refactor(cipher): Refactor the password encoder structure and optimize test cases by @gouguoyin in f904e13
- refactor(mock): data := []byte{} -> var data []byte by @gouguoyin in 40178d8
- refactor: Use
mock.NewFileinstead ofstrings.NewReaderandbytes.NewReaderby @gouguoyin in b77f6c3 - refactor: Use the
errors.Asfunction instead of type assertion by @gouguoyin in c4ddfd0 - feat: Add
FromFilemethod by @gouguoyin in a07314f - refactor: []byte{} -> var []byte by @gouguoyin in 01ebf5e
- test(crypto/cipher): Remove redundant comments by @gouguoyin in e0fb4d0
- test: TestErrorTypes -> TestRsaErrorTypes by @gouguoyin in cd0a48a
- refactor(crypto): triple_des -> tripleDes by @gouguoyin in e3add07
- feat(crypto): Add ED25519 signature and verification methods by @gouguoyin in 39f0ce3
- refactor(crypto): Update variable naming to use camelCase by @gouguoyin in 50d5d4b
- perf(crypto): Remove the error checking for the result of
hasher.Writeby @gouguoyin in 966bdd5 - refactor(mock): Added
mock/hash.goto simulate error conditions of thehash.Hashinterface by @gouguoyin in 4e38f79 - test(coding): Optimize code and add benchmark tests by @gouguoyin in ce64a33
- test(hash): Optimize code and add benchmark tests by @gouguoyin in a30f570
- feat: Implement true streaming encoding and decoding by @gouguoyin in 0fdc666
- feat: Implement true streaming hashing by @gouguoyin in 916d8f3
- refactor(mock): Improve the Sum method of ErrorHasher and add test cases by @gouguoyin in 913ef51
- feat(crypto): Refactor the ED25519 stream signature and verification logic to achieve true stream signature and verification by @gouguoyin in 704bdda
- fix(crypto): Optimize the logic of Close and ReadAll by @gouguoyin in fa1e139
- refactor(crypto): Refactor the Encrypter.stream method to implement true streaming encryption by @gouguoyin in 71ad312
- test(rc4): Optimize the test coverage for RC4 by @gouguoyin in 38b2928
- feat: Implement true streaming encryption and decryption by @gouguoyin in 961dc5d
- build: Update the version number to 1.1.1 by @gouguoyin in a2c746b
- feat(morse): Add support for spaces, punctuation marks, and special characters by @gouguoyin in 017497c
- fix(crypto/3des): Return null data when encrypting or decrypting null data by @gouguoyin in 3145828
- fix(crypto/aes): Return null data when encrypting or decrypting null data by @gouguoyin in f19243d
- fix(crypto/blowfish): Return null data when encrypting or decrypting null data by @gouguoyin in e9c1905
- fix(crypto/des): Return null data when encrypting or decrypting null data by @gouguoyin in 7ad600f
- test: Use
mock.NewFileinstead ofstrings.NewReaderandbytes.NewReaderby @gouguoyin in c70e218
v1.1.0 (2025-08-23)
⚠️ 这是一个破坏性更新版本,请慎重升级,但是强烈建议升级
✨ 新功能
- 增加对
文件流编码/解码、加密/解密、Hash/Hmac、签名/验签的支持 - 新增
ByBase32Hex编码/解码方法 base32/base32Hex编码增加对自定义字符集的支持base45编码增加对自定义字符集的支持base58编码增加对自定义字符集的支持base62编码增加对自定义字符集的支持base64/base64Url编码增加对自定义字符集的支持
🔧 重构
- 删除
BySafeURL编码/解码方法 - 删除
Sm3哈希算法(hash)和消息认证码算法(hmac) - 重命名
ByBase64URL编码/解码方法为ByBase64Url - 哈希算法(
hash)调用方式从dongle.Encrypt.ByXXX()改成dongle.Hash.ByXXX() - 消息认证码算法(
hmac)调用方式从dongle.Encrypt.ByHmacXXX()改成dongle.Hash.WithKey().ByXXX() - 重构
AES,DES,3DES,Blowfish等对称加密/解密方法,统一使用cipher.NewXXXCipher() - 重构
RSA等非对称加密/解密方法,统一使用keypair.NewXXXKeyPair()
What's Changed (55)
- Update content by @gouguoyin in 41dbddf
- Unified error handling by @gouguoyin in 79209ec
- Update introduction by @gouguoyin in 839738a
- Update references link by @gouguoyin in 178ccbf
- build: Upgrade go and dependency library version by @gouguoyin in bd915fa
- chore: Delete unnecessary directories and files by @gouguoyin in 4050bc9
- feat(coding): Add streaming encoding and decoding for base32 by @gouguoyin in bd888e4
- feat(coding): Refactor encoding and decoding for base32, and added streaming support by @gouguoyin in 3658c88
- feat(coding): Refactor encoding and decoding for base45, and added streaming support by @gouguoyin in 4a9e5f1
- feat(coding): Refactor encoding and decoding for base58, and added streaming support by @gouguoyin in 94af864
- feat(coding): Refactor encoding and decoding for base62, and added streaming support by @gouguoyin in ec8cf47
- feat(coding): Refactor encoding and decoding for base64, and added streaming support by @gouguoyin in fab63f8
- feat(coding): Refactor encoding and decoding for base85, and added streaming support by @gouguoyin in 12b8686
- feat(coding): Refactor encoding and decoding for base91, and added streaming support by @gouguoyin in 6253df9
- feat(coding): Refactor encoding and decoding for base100, and added streaming support by @gouguoyin in 7938084
- feat(coding): Refactor encoding and decoding for hex, and added streaming support by @gouguoyin in 90421f9
- feat(coding): Refactor encoding and decoding for morse, and added streaming support by @gouguoyin in e556a27
- test(coding): Add unit tests and examples for Base32 encoding and decoding by @gouguoyin in 49e8824
- test(coding): Add unit tests and examples for Base45 encoding and decoding by @gouguoyin in 8bb6af4
- test(coding): Add unit tests and examples for Base58 encoding and decoding by @gouguoyin in 9acead1
- test(coding): Add unit tests and examples for Base62 encoding and decoding by @gouguoyin in 0e759d4
- test(coding): Add unit tests and examples for Base64 encoding and decoding by @gouguoyin in 56b939f
- test(coding): Add unit tests and examples for Base85 encoding and decoding by @gouguoyin in e3c40d3
- test(coding): Add unit tests and examples for Base91 encoding and decoding by @gouguoyin in 581084d
- test(coding): Add unit tests and examples for Base100 encoding and decoding by @gouguoyin in 8a649aa
- feat(coding): Add a universal decoder by @gouguoyin in 56e267d
- feat(coding): Add a universal encoder by @gouguoyin in df83e3d
- test(coding): Add Decoder unit test by @gouguoyin in c8cd146
- test(coding): Add Encoder unit test by @gouguoyin in 9ffeeb2
- test(coding): Add unit tests and examples for Hex encoding and decoding by @gouguoyin in 7f0ebed
- test(coding): Add unit tests and examples for Morse encoding and decoding by @gouguoyin in e090a75
- feat(utils): Add string and byte slice conversion tools by @gouguoyin in 3d8531a
- feat: Create a dongle package and initialize the basic structure by @gouguoyin in be20106
- test(mock): Add mock file implementation and related tests by @gouguoyin in 4966d26
- feat(hash): Reconstruct hash algorithm by @gouguoyin in a72d1b5
- feat(crypto): Reconstruct crypto algorithm by @gouguoyin in 935cb7f
- test: xxx_unit_test.go -> xxx_test.go by @gouguoyin in a015292
- feat: Add a Hasher instance by @gouguoyin in 421a980
- build: Update the dependency version in
go.modby @gouguoyin in 195b44c - docs: Add a Japanese README file by @gouguoyin in 64b7b5c
- build: Update import path by @gouguoyin in 290a5d2
- docs: Update the code coverage badge link in the README file by @gouguoyin in 918a4c7
- docs:HASH -> Hash, HMAC -> Hmac by @gouguoyin in bfe4ef9
- refactor: Unify import sequence by @gouguoyin in 1312eb8
- refactor(rsa): Reconstruct signature and verification by @gouguoyin in f5bda3f
- refactor(crypto): Support streaming decryption by @gouguoyin in a3fdee1
- docs(README): Update project documents and logo links by @gouguoyin in a7c712b
- ci: Update workflow configuration and code coverage branch by @gouguoyin in 1f09724
- ci: Update workflow configuration by @gouguoyin in 1956fbc
- ci: Update code coverage branch by @gouguoyin in dfb63f6
- test: Remove utils/converter_example_test.go by @gouguoyin in 17e9909
- ci: Update the testing workflow to include all directories by @gouguoyin in f2c8a46
- feat: Add version number constant by @gouguoyin in f6f6061
- docs(readme): Update the README file in multiple languages by @gouguoyin in 28993a4
- docs: Update the project introduction in the README file by @gouguoyin in eb8def1
v1.0.1 (2024-11-22)
✨ 新功能
base62支持自定义编码表
🐛 修复
- 修复
AES-CBC-PKCS5加密解密错误的 bug
🔧 重构
- 优化代码质量和组织结构
- 删除
errors.go文件,将错误信息迁移到各个文件里 - 统一单元测试格式
- 移除中文注释
What's Changed (22)
- Changed badge url by @gouguoyin in 5f1a726
- update by @gouguoyin in 2703673
- Changed badge address by @gouguoyin in 343a3c2
- 修改徽章地址 by @gouguoyin in 0a934f5
- Unified Unit test Format by @gouguoyin in 09b1657
- Bump codecov/codecov-action from 4 to 5 by @gouguoyin in cee97bf
- Support custom alphabet table by @gouguoyin in 3d21a8e
- Support custom alphabet table for base62 by @gouguoyin in e53528a
- Remove benchmark file by @gouguoyin in 77fb897
- Remove errors from errors.go to the current file by @gouguoyin in c286a54
- Remove Chinese annotations by @gouguoyin in c969116
- Change key type from
interface{}to[]byteby @gouguoyin in 1f43106 - Change privateKey and publicKey type from
interface{}to[]byteby @gouguoyin in d92e678 - Upgrade version by @gouguoyin in 7afcd5e
- github.com/golang-module/dongle -> github.com/dromara/dongle by @gouguoyin in 34d2c49
- Add
WithKeyandWithIVmethods by @gouguoyin in fdef30b - Remove github.com/golang-module/dongle by @gouguoyin in 42685d4
- Remove errors.go by @gouguoyin in f0b67fb
- Update content about
base62by @gouguoyin in 3623058 - Update content by @gouguoyin in 4a68d5f
- Upgrade version to
1.0.1by @gouguoyin in f81202d - Remove useless type conversions by @gouguoyin in 42d5ae3
v1.0.0 (2024-11-11)
🐛 修复
- 修复了 AES/ECB/PKCS5 填充导致的 panic
📝 文档
- 更改了仓库和徽章 URL
What's Changed (5)
- Fixed: AES/ECB/PCKS5padding panic by xiaoyiyu in 5497c86
- Update content by @gouguoyin in f009269
- Upgrade version by @gouguoyin in 3293d42
- golang-module/dongle->dromara/dongle by @gouguoyin in de7c99b
- Changed badge url by @gouguoyin in 50691b6
有关更早版本的更新日志,请参阅 releases