simpleHashsimpleHash 函数接收一个字符串,并为其生成一个简短、稳定的哈希值。这对于需要根据输入字符串生成唯一但可预测的标识符(例如,用作 DOM ID 或 class 名称)的场景非常有用。
import { simpleHash } from '@movk/core'
// 相同的输入总是产生相同的输出
const hash1 = simpleHash('hello world')
const hash2 = simpleHash('hello world')
// hash1 === hash2
// => true
// 不同的输入产生不同的输出
const hash3 = simpleHash('hello there')
// hash1 !== hash3
// => true
console.log(hash1) // => "nf5xd4"
simpleHash(str: string): string