From 118609d38d80d1f3252a02e27f2f9ba18504d118 Mon Sep 17 00:00:00 2001 From: AI Engineer Date: Sun, 21 Jun 2026 23:02:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(id):=20ExchangeInt+HashInt=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=80=BC=E6=9C=AA=E8=A2=AB=E8=B5=8B=E5=80=BC=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20ID=20=E6=9C=AA=E6=89=93=E4=B9=B1=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=BA=20hash=20=E5=AD=97=E8=8A=82=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E4=B8=BA=20base62=20=E6=95=B0=E5=AD=97=EF=BC=88by=20A?= =?UTF-8?q?I=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: deepseek-v4-pro[1m] --- id.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/id.go b/id.go index 82995ff..0c75e9c 100644 --- a/id.go +++ b/id.go @@ -86,7 +86,12 @@ func (im *IDMaker) get(size int, ordered bool, hashToHead bool) string { uid = append(uid, inSecIndexBytes...) uid = intEncoder.FillInt(uid, size) if !ordered { - encoding.HashInt(encoding.ExchangeInt(uid), nil) + uid = encoding.ExchangeInt(uid) + hashed := encoding.HashInt(uid, nil) + uid = make([]byte, 0, size) + for i := 0; i < size && i < len(hashed); i++ { + uid = append(uid, intEncoder.EncodeInt(uint64(hashed[i]))[0]) + } } else { encoding.HashInt(encoding.ExchangeInt(uid[secLen+1:]), nil) if hashToHead {