---
title: "simpleHash"
description: "生成字符串的轻量哈希值，适合用于缓存 key、去重标识等非加密场景。"
seo_title: "simpleHash"
seo_description: "Generate a fast non-cryptographic hash of a string as a base-36 encoded value, handy for cache keys and lightweight fingerprints."
canonical_url: "https://core.mhaibaraai.cn/docs/helpers/simple-hash"
---
# simpleHash

> 生成字符串的轻量哈希值，适合用于缓存 key、去重标识等非加密场景。

## 用法

`simpleHash` 函数用于生成字符串的简单哈希值。

```ts
import { simpleHash } from '@movk/core'

const hash1 = simpleHash('hello world')
console.log(hash1) // 'nf5xd4'

const hash2 = simpleHash('hello world')
console.log(hash1 === hash2) // true，相同字符串产生相同哈希

const hash3 = simpleHash('hello world!')
console.log(hash1 === hash3) // false，不同字符串产生不同哈希
```

## API

### `simpleHash(str)`

生成字符串的简单哈希值。

### 参数

**str** (`string`) *required*: 待哈希的字符串。

### 返回值

**返回值** (`string`): 32 位哈希值转换为 36 进制字符串。

## Changelog

See commit history for [src/helpers/simpleHash.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/helpers/simpleHash.ts).


## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
