### Fixed

- Unpaired UTF-16 surrogates produce wrong digests and consume the next code unit in the JS path. Unpaired surrogates are now encoded as U+FFFD, matching `TextEncoder` and Node.js `crypto`. #57

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Yi-Cyuan Chen
2026-11-16 16:37:59 +08:00
co-authored by Claude Opus 5.5
parent ee1c332b60
commit 68b5c32442
27 changed files with 273 additions and 111 deletions
+10
View File
@@ -27,6 +27,16 @@
'edce615b179e6e29be23145b77ebbd61': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
'ad36c9ab669a0ba9ce46d3ce9134de34': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
},
'UTF8 unpaired surrogates': {
'9b759040321a408a5c7768b4511287a6': '\ud800',
'e240e5e976deb550ea69ec12f01d19ea': '\udc00x',
'ff6405018d5ab2642e35fdba389b7c51': 'a\ud83db',
'ef175e9b596d296034dda690087252f8': 'a\udc00',
'2e906629739ba554e03c1201e05b94f2': '\ud83d\ud83d\ude00',
'468a7f02af0808ae39ef3e3629ae048c': '\ud83d\ude00\udfff',
'6785af8cb378bd9950085c5d6375f9ad': Array(57).join('0') + '\ud800',
'a20fb4cd303a71aa61dd524e8fc525ef': Array(64).join('0') + '\ud800b'
},
'special length': {
'a119de63e4b2398427da06dd780263b3': '0123456780123456780123456780123456780123456780123456780',
'ddafd84ebe63aebc4626b037a569d78b': '01234567801234567801234567801234567801234567801234567801',