mirror of
https://gitee.com/ShopeX/ECShopX_admin-frontend
synced 2026-07-21 06:25:38 +08:00
15 lines
306 B
JavaScript
Executable File
15 lines
306 B
JavaScript
Executable File
function generateId(key) {
|
|
let hash = 0
|
|
for (let i = 0; i < key.length; i++) {
|
|
const charCode = key.charCodeAt(i)
|
|
hash = (hash << 5) - hash + charCode
|
|
hash = hash & hash
|
|
}
|
|
const id = Math.abs(hash).toString(36) + key.length.toString(36)
|
|
return id
|
|
}
|
|
|
|
module.exports = {
|
|
generateId
|
|
}
|