Skip to content

Change Log ​

v1.3.0 (2026-10-19) ​

✨ Features ​

  • Add ASN.1 ciphertext and signature formats to SM2: Sm2CipherMode gains ASN1C1C2C3 and ASN1C1C3C2, so ciphertext can be encoded as the DER SEQUENCE { x INTEGER, y INTEGER, C2 OCTET STRING, C3 OCTET STRING } that BouncyCastle, Java and most national-crypto gateways produce, instead of only the raw C1 || C2 || C3 / C1 || C3 || C2 byte layout; Sm2SingMode (ASN1 as the default, Bytes) and SetSingMode are added so a signature is either a DER SEQUENCE { r, s } or a fixed 64-byte r || s; both formats are parsed with cryptobyte, so a truncated or non-DER payload returns an error instead of being silently misread, and NewSm2KeyPair keeps ASN1 as the default (by @Web-Coke in #40)
  • Extend the morse alphabet to the full ITU-R M.1677-1 table and the international extended characters: adds ¡, ¿, å/Å, ä/Ä, é/É, ñ/Ñ, ó/Ó, ö/Ö and ú/Ú with the codes published by codigomorse.org, documents which ITU section each group comes from, and moves / into the punctuation group; note that two existing mappings change — < moves from .--.- to .--.-- because .--.- now belongs to å, and \n becomes .-..-.., which also separates it from \r; text encoded with v1.2.3 decodes differently for those two characters (by @htlsmilework in #42)

🐛 Fixes ​

  • Fix ascii85 decoding truncating its output when z shortcuts are present: encoding/ascii85 emits a single z for an all-zero four-byte group and the encoder here does the same, but the decoder recomputed the destination length from the character count at a strict 5:4 ratio and truncated the standard library's correct answer to it, so five zero bytes round-tripped to two, and eight zero bytes to one, without any error; z is now excluded from the ratio and counted as four bytes, and the destination is sized for the expansion a shortcut implies (by @youdie006 in #44)
  • Fix ascii85 decoding failing for four or more zero groups: the u padding still used len(src)%5 after the length fix above, so with z shortcuts present the final group could be left with a single character, which encoding/ascii85 rejects — sixteen zero bytes, encoded as zzzz, did not decode at all; both decoders now pad by the non-z length (by @youdie006 in #47)
  • Fix base58 and base62 streams producing different output from the bulk API: both alphabets treat the input as a single big number, so it cannot be split into independent chunks, yet the stream encoder encoded every 8 bytes separately and the stream decoder decoded every 1024 bytes separately — Encode.FromFile(...).ByBase58() and ByBase62() returned a different result than FromBytes() for the same data, and that result did not decode back; the stream encoder now buffers the input and encodes it once in Close, as its documentation already described, and the decoder reads all of the encoded input and decodes it once, releasing its buffers as the decoded data is consumed (by @Shaisolaris in #48)
  • Fix key pairs rejecting keys generated by other tools and panicking on a key of the wrong algorithm: a key was only accepted when it was byte for byte the output of GenKeyPair, i.e. a PUBLIC KEY/PRIVATE KEY PEM block holding PKIX or PKCS#8 DER; the base64 and raw material printed by most SM2 and Ed25519 generators failed with invalid public key: <nil> or an unintelligible ASN.1 error, and an RSA key passed to an Ed25519 key pair panicked because the result of the type assertion was never checked (#41); every Parse*, Format* and Set* method now goes through a shared selector that tries the input as PEM, base64 (all four alphabets, with or without padding), hex and bare key material, and lets the algorithm-specific parser pick the interpretation that works — Ed25519 accepts PKIX/PKCS#8 DER, a 32-byte seed and a 64-byte private key, SM2 accepts PKIX/PKCS#8 DER, a 65-byte uncompressed point and a 32-byte scalar, RSA accepts PKIX/PKCS#1 DER; SM2 key formatting now uses a local SPKI/PKCS#8 encoder because crypto/x509 has no SM2 support, so the output still parses in OpenSSL and Java; Set*Key accept PEM and normalize it, a block of another algorithm or direction is rejected before parsing with UnsupportedKeyFormatError ("the parsed key is an RSA key, not an Ed25519 key"), the error messages no longer print <nil>, Compress*Key use pem.Decode instead of string surgery so optional headers are handled, and the SM2 private scalar is validated to be in [1, n-1] — d = 0 used to produce a key without a public point (by @gouguolei in 012269d)

⚡ Performance ​

  • Derive the morse reverse alphabet once instead of scanning it per symbol: StdDecoder.Decode ranged over the whole StdAlphabet until it found a matching code, making decoding O(n × 89) where it should be O(n) and spending 53% of a CPU profile in map iteration; the inverse map is now built once in init(), the way base45 and base91 already derive their decode tables, cutting the geomean by 89.21% (4096 characters: 1222µs → 103µs) with allocations unchanged; the scan also made decoding non-deterministic, because seven codes are shared by an upper- and lower-case pair (Å/å for .--.-, and likewise for ä, é, ñ, ó, ö, ú) and ranging over a map picks a random winner, so .--.- decoded to Å 62% of the time and encoding-then-decoding those characters was not lossless; the inverse map resolves such collisions to the lower-case form, which is the only one Encode can produce (by @darakanoit in #46)

🔧 Refactors ​

  • Route key serialization through package-level helpers: marshalPKIXPublicKey and marshalPKCS8PrivateKey are now variables wrapping crypto/x509, and marshalSm2PublicKey/marshalSm2PrivateKey wrap the local SM2 encoder, so the error branches of Format*Key can be simulated in tests, since crypto/x509 never fails for a key that has already been parsed into its typed form; RSA, Ed25519 and SM2 formatting all use them (by @gouguolei in e314c99 6ad47b4 0769ea0 2c9ad5a)
  • Simplify the RSA stream verifier and drop unused stream buffers: rsa.StreamVerifier.verify returns only an error instead of a valid flag that was always true when the error was nil, unicode.StreamEncoder and unicode.StreamDecoder lose their unused fixed [512]byte buffers, and the morse error message uses a plain string literal instead of fmt.Sprintf with no verbs (by @gouguolei in 68dad92)
  • Fix an inverted SetSingMode assertion and initialize the SM2 default explicitly: the clamp test expected SingMode to stay ASN1 after SetSingMode(Bytes), which cannot happen because the setter simply assigns, and NewSm2KeyPair relied on the zero value being ASN1; the constructor now sets SingMode: ASN1 and the test asserts both directions (by @gouguolei in 079efab)
  • Clean up and extend the test suite: removes unused variables and duplicated cases from 24 test files, adds key_format_test.go and key_test.go covering the key material helpers, every UnsupportedKeyFormatError message and the rejection paths of the public API, and covers the SM2 DER and private scalar range branches, raising keypair statement coverage to 97.7% (by @gouguolei in 372209d 12c3e11)

🚀 CI ​

  • Add a golangci-lint workflow and configuration: lint.yml runs golangci-lint-action@v9 pinned to v2.15.0 on pushes and pull requests to master with contents: read; .golangci.yml enables the standard set plus misspell, unconvert, unparam and whitespace, disables the opinionated staticcheck style checks (ST1000–ST1022, QF1001) and excludes (io.Seeker).Seek from errcheck because rewinding a stream is best-effort by design; the READMEs drop the Go Report Card badge in favour of the workflow status badge (by @gouguolei in 1487675 0517244)

📝 Docs ​

  • Serve the README images from the repository instead of the docs site: the logo, the GVP and G-Star banners and the JetBrains logo now point at assets/, so the English, Chinese and Japanese READMEs no longer depend on 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) ​

✨ Features ​

  • Let an RSA key pair hold only the key its operation needs: RsaKeyPair gains a Type field, set through SetType, together with the new KeyType type and its PublicKey / PrivateKey constants; NewStdEncrypter, NewStdDecrypter, NewStdSigner, NewStdVerifier and their streaming counterparts branch on it, so a key pair carrying only a public key can encrypt and verify and one carrying only a private key can decrypt and sign, and the public key can also be the signing side when a private key is the verifier; an empty Type falls back to the sensible side per operation — PublicKey for encrypt and verify, PrivateKey for decrypt and sign — and the default padding follows the key format, PKCS1 keys using PKCS1v15 and PKCS8 keys using OAEP for encryption and PSS for signing, with OAEP rejected for signing and PSS for encryption through UnsupportedPaddingSchemeError; the padding for both key sides and every combination is now implemented in crypto/internal/rsa, including the PSS encoding and MGF1 that Go's crypto/rsa only exposes for one direction (by @gouguoyin in 12ffe48 eb81cbc 33ac684 749b690)
  • Add SetMode to Sm2KeyPair and rename CipherOrder to Sm2CipherMode: SetMode becomes the documented way to pick the ciphertext order and SetOrder is kept as a thin alias so existing calls still compile; the type rename only breaks code that spelled CipherOrder out, and the order parameter is renamed to mode throughout so it no longer collides with the word used for key ordering (by @gouguoyin in 858d8b8 3785a02 6d30805 56b6b15)

🔧 Refactors ​

  • Remove LoadPublicKey and LoadPrivateKey from Sm2KeyPair: SM2 was the last key pair that read files itself, so a caller had to hand it an fs.File; read the file and pass the bytes to SetPublicKey / SetPrivateKey instead, the way RSA and Ed25519 already work (by @gouguoyin in e4d6e3c)
  • Split crypto/sm2 into encrypt.go, decrypt.go, sign.go and verify.go and rename the internal helpers to EncryptWithPublicKey, DecryptWithPrivateKey, SignWithPrivateKey and VerifyWithPublicKey, so the direction each function needs is visible at the call site; the redundant SM2 implementation is deleted, the auxiliary functions move to their own files, and the priv field is renamed to pri to match the rest of the package (by @gouguoyin in 86819de 1602745 0dfd8ea c0a45e4 ccc968f f876923)
  • Cache the parsed Ed25519 keys: the signer and verifier used to parse the PEM on every call and duplicated the parsing logic that lives in crypto/keypair; both now cache the parsed key once, the duplicate code is gone, and the package is split into ed25519.go, sign.go and verify.go (by @gouguoyin in 0ed7ca5)
  • Delete the redundant cipher creation in the RC4 fallback path: the fallback branch built a cipher that was immediately discarded (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 SetMode method to replace the existing SetOrder method 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) ​

✨ Features ​

  • Add SM2 signing and verification to the fluent API: Signer.BySm2 and Verifier.BySm2 are added for both standard and streaming processing, so SM2 joins RSA and Ed25519 and a signature can be produced with the private key and checked with the public key in the same chain; Sm2KeyPair.SetUID sets the user identity mixed into ZA, which stays 1234567812345678 when unset; verification reports an empty signature as EmptySignatureError before any curve arithmetic happens (by @gouguoyin in b72066e 0382cd6 39d00c3)
  • Add RSA padding scheme selection: the new RsaPaddingScheme type exposes PKCS1v15, OAEP and PSS, chosen with SetPadding; PKCS1v15 works for both encryption and signing, OAEP only for encryption and requires a hash set through SetHash, PSS only for signing; when no padding is set it follows the key format, PKCS1 keys falling back to PKCS1v15 and PKCS8 keys to OAEP, and an unsupported combination returns UnsupportedPaddingSchemeError instead of an opaque standard-library error (by @gouguoyin in d1734dc b4173be d08e5fc)
  • Add separate key and signature error types: EmptyPrivateKeyError, EmptyFormatError, UnsupportedKeyFormatError, EmptyPaddingError, UnsupportedPaddingSchemeError and EmptySignatureError replace the single catch-all, so a missing key can be told apart from a malformed one (by @gouguoyin in 856dd51)

🐛 Fixes ​

  • Fix RSA decryption failing for PKCS#1 v1.5 ciphertext when the private key is stored as PKCS#8 (#39): with Format set to PKCS8 and no explicit padding, decryption fell back to OAEP, so data encrypted by JSEncrypt or by PHP's openssl_* defaults failed with crypto/rsa: decryption error even though PHP itself decrypted it; the padding is now selectable through SetPadding and the key pair from the report is kept as a regression test (by @gouguoyin in 27c69f6)
  • Remove the redundant signature length check from RSA verification: the guard rejected signatures produced by other libraries before rsa.Verify* had a chance to validate them, while the standard library already reports a clear error for a malformed length (by @gouguoyin in faa99bb)

⚡ Performance ​

  • Avoid one copy when morse encoding and decoding return their result: []byte(builder.String()) is replaced with utils.String2Bytes, which reuses the builder's buffer instead of copying it once more, which matters for large payloads where the output is already the dominant allocation (by @gouguoyin in 10d2eb0)

🔧 Refactors ​

  • Rename the key format and cipher order types per algorithm: KeyFormat becomes RsaKeyFormat and CipherOrder becomes Sm2CipherOrder, so neither carries a generic name that reads as if it applied to every algorithm; NoSignatureError becomes EmptySignatureError, UnsupportedPemTypeError becomes UnsupportedKeyFormatError and Ed25519KeyPair.Sign becomes Signature (by @gouguoyin in 37d5a1a ac77cf7 6135756 8a6ea39)
  • Rewrite the RSA encrypt, decrypt, sign and verify paths: each operation now resolves its padding once when the encrypter, decrypter, signer or verifier is created and dispatches on it, so a PSS request reaching the encryption path or a missing hash for OAEP is reported up front instead of failing mid-stream (by @gouguoyin in d08e5fc)
  • Rename the streaming decryptor fields from decrypted to buffer and from pos to position across 3DES, AES, Blowfish, DES, Tea, XTea, Twofish, SM4 and Salsa20, and simplify how the 3DES streaming decryptor slices its input (by @gouguoyin in 114d3be efefe59 e66e508 ba303e7 4d93579 e0b9f3b 5f311b4 426506a f375496 ce101f1)
  • Hold the Ed25519 key pair by value in StdSigner and StdVerifier instead of by pointer, so a key pair mutated after construction cannot change an operation that is already running, and simplify the Ed25519 error types (by @gouguoyin in b5cd502 225b70f)
  • Move mock and utils into internal: the test helper and the zero-copy helpers are no longer importable from outside the module, and the SM4 implementation moves into crypto/internal/sm4 (by @gouguoyin in ef82486 fe841a7)
  • Rename the internal sm2curve package to sm2 and align the stdAsn1 alias with the encodingAsn1 naming used elsewhere (by @gouguoyin in 14e9818 cf69603)
  • Simplify the tests: mock.File from internal/mock replaces the per-test reader mocks, every test closes the files it opens, and the Chinese comments are translated to English (by @gouguoyin in 6b021d7 3ea3710 bd8b1b3 7fb2ddc 9a4b693 2cab5e7 bbc4123 ee77460)

📝 Docs ​

  • Update the key pair package documentation and the RSA usage instructions to cover the new padding and key format types (by @gouguoyin in dafc7cf b765056 399de93)
What's Changed (38)

v1.2.1 (2025-11-24) ​

✨ Features ​

  • Add direct parsing support for BIT_STRING format keys in Sm2 asymmetric elliptic curve encryption algorithm

🐛 Fixes ​

  • Fix bug where wNAF algorithm error in Sm2 asymmetric elliptic curve encryption algorithm causes decryption failure in some cases

⚡ Performance ​

  • Optimize curve field element operation implementation in Sm2 asymmetric elliptic curve encryption algorithm

🔧 Refactors ​

  • Simplify test loop syntax, change from for loop to range loop
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) ​

✨ Features ​

  • RSAKeyPair struct adds FormatPublicKey and FormatPrivateKey methods to format base64 encoded der format RSA public and private keys into pem format
  • Ed25519KeyPair struct adds FormatPublicKey and FormatPrivateKey methods to format base64 encoded der format Ed25519 public and private keys into pem format
  • RSAKeyPair struct adds CompressPublicKey and CompressPrivateKey methods to compress pem format RSA public and private keys into base64 encoded der format
  • Ed25519KeyPair struct adds CompressPublicKey and CompressPrivateKey methods to compress pem format Ed25519 public and private keys into base64 encoded der format
  • Add Sm2 asymmetric elliptic curve encryption algorithm support, including standard processing and streaming processing

⚡ Performance ​

  • Optimize encoder and decoder performance, reuse read buffer, reduce memory allocation and copying

🔧 Refactors ​

  • Remove LoadPublicKey and LoadPrivateKey methods from RSAKeyPair struct
  • Remove LoadPublicKey and LoadPrivateKey methods from Ed25519KeyPair struct
  • RSAKeyPair struct's GenKeyPair, SetPublicKey, SetPrivateKey methods changed from no return value to returning error
  • Ed25519KeyPair struct's GenKeyPair, SetPublicKey, SetPrivateKey methods changed from no return value to returning error
What's Changed (25)
  • chore(dongle): Update package meta and version number by @gouguoyin in ab46cdb
  • feat(mock): Add Error WriteAfterN struct, 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 src to []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) ​

✨ Features ​

  • Add Unicode encoding/decoding support, including standard processing and streaming processing
  • Add TBC padding mode support for symmetric block encryption algorithms

🐛 Fixes ​

  • Fix bug where *RsaKeyPair.formatPublicKey and *RsaKeyPair.formatPrivateKey fail to format keys
  • Fix bug where *Ed25519KeyPair.formatPublicKey and *Ed25519KeyPair.formatPrivateKey fail to format keys
  • Fix bug where decoding encrypted ciphertext fails during decryption and the error cannot be retrieved

🔧 Refactors ​

  • Change default padding mode from PKCS7 to No in symmetric block encryption algorithms
What's Changed (36)

v1.1.7 (2025-10-20) ​

✨ Features ​

  • Add sm4 chinese national standard block encryption algorithm support, including standard processing and streaming processing, supporting different block modes and padding modes

🐛 Fixes ​

  • Fix bug in asymmetric digital signature algorithm verification #30
  • Optimize streaming processing logic, add support for reader position reset to ensure reading from the beginning of the data source, avoiding position offset issues caused by previous read operations, ensuring completeness and correctness of streaming operations

🔧 Refactors ​

  • Change private methods newXXXEncrypter and newXXXDecrypter series in crypto/cipher/block.go to public methods NewXXXEncrypter and NewXXXDecrypter
  • Change private methods newXXXPadding and newXXXUnPadding series in crypto/cipher/padding.go to public methods NewXXXPadding and NewXXXUnPadding
What's Changed (38)

v1.1.6 (2025-10-12) ​

✨ Features ​

  • Optimize tea encryption algorithm to support different block modes and padding modes
  • Add xtea encryption algorithm support, including standard processing and streaming processing

🔧 Refactors ​

  • Use io.CopyBuffer to simplify streaming processing logic
What's Changed (26)
  • docs(readme): Update the import path in README.cn.md by @gouguoyin in dbe8da4
  • refactor: Rename the util package to utils by @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.go to doc.go by @gouguoyin in 0a86b4a
  • refactor(utils): Add package comment in doc.go by @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.6 by @gouguoyin in 4a16814
  • refactor(hash): Use io.CopyBuffer to replace manual reading of the buffer, simplifying the implementation of stream and hmac methods 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.CopyBuffer to 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.CopyBuffer by @gouguoyin in bc1c6ab
  • refactor(encoder):Simplify streaming process with io.CopyBuffer by @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 xtea algorithm 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) ​

🐛 Fixes ​

  • Fix bug where symmetric encryption algorithms incorrectly perform padding on block modes that don't require padding (such as CFB/OFB/CTR/GCM, etc.), causing encryption/decryption errors
What's Changed (6)

v1.1.4 (2025-09-23) ​

✨ Features ​

  • Add twofish encryption algorithm support, including standard processing and streaming processing

🔧 Refactors ​

  • Change method receivers from pointer to value to prevent property pollution when using global default instances, with no impact on caller API
What's Changed (5)

v1.1.3 (2025-09-15) ​

✨ Features ​

  • Update testify dependency to v1.11.1

🐛 Fixes ​

  • Optimize 3DES symmetric encryption algorithm compatibility with 16-byte keys
  • Optimize DES symmetric encryption algorithm validation for unsupported GCM mode
  • Optimize 3DES symmetric encryption algorithm validation for unsupported GCM mode
  • Optimize Blowfish symmetric encryption algorithm validation for unsupported GCM mode

🔧 Refactors ​

  • Add Salsa20 encryption algorithm support, including standard processing and streaming processing
What's Changed (21)

v1.1.2 (2025-09-08) ​

✨ Features ​

  • Encoding/decoding support customizing file stream buffer size via coding.BufferSize global variable
  • Encryption/decryption support customizing file stream buffer size via crypto.BufferSize global variable
  • Hash/Hmac algorithms support customizing file stream buffer size via hash.BufferSize global variable
  • Add Blake2b hash algorithm support, including blake2b-256, blake2b-384 and blake2b-512
  • Add Blake2s hash algorithm support, including blake2s-128 and blake2s-256
  • Add ChaCha20 encryption algorithm support
  • Add ChaCha20Poly1305 encryption algorithm support
What's Changed (24)

v1.1.1 (2025-09-01) ​

✨ Features ​

  • Encoding/decoding, encryption/decryption, Hash/Hmac, signature/verification support true streaming processing
  • Add ED25519 digital signature and verification support
  • Add SM3 hash algorithm support
  • coding/morse/morse.go adds support for spaces, punctuation, and special characters

⚡ Performance ​

  • When input data is empty, return empty data directly without executing subsequent operations

🔧 Refactors ​

  • Symmetric encryption algorithms changed from ByXXX(cipher.XXXCipher) to ByXXX(*cipher.XXXCipher)
  • Change toolkit package name from utils to util
  • Add mock/hash.go to simulate errors in hash.Hash interface
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 SM3 hash 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.Rc4Cipher to *cipher.Rc4Cipher by @gouguoyin in 4bcba4e
  • refactor(tea): cipher.TeaCipher -> *cipher.TeaCipher by @gouguoyin in f90f82c
  • refactor(tea): cipher.BlowfishCipher -> *cipher.BlowfishCipher by @gouguoyin in af4db9d
  • refactor(crypto/cipher):Rename the padding function and remove the internal dispatcher by @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.NewFile instead of strings.NewReader and bytes.NewReader by @gouguoyin in b77f6c3
  • refactor: Use the errors.As function instead of type assertion by @gouguoyin in c4ddfd0
  • feat: Add FromFile method 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.Write by @gouguoyin in 966bdd5
  • refactor(mock): Added mock/hash.go to simulate error conditions of the hash.Hash interface 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.NewFile instead of strings.NewReader and bytes.NewReader by @gouguoyin in c70e218

v1.1.0 (2025-08-23) ​

⚠️ This is a breaking change version, please upgrade with caution, but it is strongly recommended to upgrade

✨ Features ​

  • Add support for file stream encoding/decoding, encryption/decryption, Hash/HMAC, signature/verification
  • Add new ByBase32Hex encoding/decoding method
  • Add support for base32/base32Hex encoding custom character
  • Add support for base45 encoding custom character
  • Add support for base62 encoding custom character
  • Add support for base64/base64Url encoding custom character

🔧 Refactors ​

  • Delete BySafeURL encoding/decoding method
  • Delete Sm3 hash algorithm (hash) and message authentication code algorithm (hmac)
  • Rename ByBase64URL encoding/decoding method to ByBase64Url
  • Hash algorithm (hash) calling method changed from dongle.Encrypt.ByXXX() to dongle.Hash.ByXXX()
  • Message authentication code algorithm (hmac) calling method changed from dongle.Encrypt.ByHmacXXX() to dongle.Hash.WithKey().ByXXX()
  • Refactor AES, DES, 3DES, Blowfish and other symmetric encryption/decryption methods, uniformly use cipher.NewXXXCipher()
  • Refactor RSA and other asymmetric encryption/decryption methods, uniformly use keypair.NewXXXKeyPair()
What's Changed (55)

v1.0.1 (2024-11-22) ​

✨ Features ​

  • base62 supports custom encoding tables

🐛 Fixes ​

  • Fix bug with AES-CBC-PKCS5 encryption/decryption errors

🔧 Refactors ​

  • Optimize code quality and organizational structure
  • Delete errors.go file, migrate error messages to individual files
  • Unify unit test format
  • Remove Chinese comments
What's Changed (22)

v1.0.0 (2024-11-11) ​

🐛 Fixes ​

  • Fixed panic caused by AES/ECB/PKCS5 padding

📝 Docs ​

  • Changed repository and badge urls
What's Changed (5)

For change logs of earlier versions, please refer to releases

Released under the MIT License, unauthorized reproduction is prohibited in any form