js _generatePluginIDFromBytesb return createHashsha256 updateb digesthex slice0 32 split mapchar = return char = a StringfromCharCodecharcharCodeAt + 10
import (
"crypto/sha256"
"encoding/hex"
"strconv"
)
func generatePluginIDFromBytes(b []byte) string {
hash := sha256.Sum256(b)
hashHex := hex.EncodeToString(hash[:])
hashSlice := hashHex[:32]
result := ""
for _, char := range hashSlice {
if char >= 'a' {
result += strconv.Itoa(int(char) + 10)
} else {
result += strconv.Itoa(int('a') + int(char) - int('0'))
}
}
return result
}
原文地址: http://www.cveoy.top/t/topic/iDcJ 著作权归作者所有。请勿转载和采集!