Skip to content

Commit e9fd678

Browse files
committed
update docs
1 parent 6e785c5 commit e9fd678

File tree

2 files changed

+4
-24
lines changed
  • docs
    • api/scripts/builtin-modules
    • zh/api/scripts/builtin-modules

2 files changed

+4
-24
lines changed

docs/api/scripts/builtin-modules/hash.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ hash.md5(input: <string|bytes>)
2525
::: warning Important Notes
2626
- **String parameter is only for file paths**: If a string is passed, the function will calculate the hash value of that file
2727
- **Binary data must use bytes parameter**: To calculate the hash value of binary data, you must wrap the data with the `bytes()` function
28-
- **String data hashing**: To calculate the hash value of string data, please use `hash.strhash32`, `hash.strhash64`, or `hash.strhash128` interfaces
2928
- **Common mistake**: If the file doesn't exist, the function will incorrectly treat the file path as string data to calculate the hash value, and it won't report an error, resulting in incorrect results
3029
:::
3130

@@ -58,9 +57,7 @@ print("MD5: " .. checksum)
5857
-- ❌ Wrong: If "hello" is not a file path, it will incorrectly calculate the hash of the file path string
5958
local checksum = hash.md5("hello")
6059

61-
-- ✅ Correct: Use strhash interface to calculate string hash value
62-
local checksum = hash.strhash32("hello")
63-
-- Or use bytes wrapper
60+
-- ✅ Correct: Use bytes wrapper for binary data
6461
local checksum = hash.md5(bytes("hello"))
6562
```
6663

@@ -86,7 +83,6 @@ hash.sha1(input: <string|bytes>)
8683
::: warning Important Notes
8784
- **String parameter is only for file paths**: If a string is passed, the function will calculate the hash value of that file
8885
- **Binary data must use bytes parameter**: To calculate the hash value of binary data, you must wrap the data with the `bytes()` function
89-
- **String data hashing**: To calculate the hash value of string data, please use `hash.strhash32`, `hash.strhash64`, or `hash.strhash128` interfaces
9086
:::
9187

9288
#### Usage
@@ -131,7 +127,6 @@ hash.sha256(input: <string|bytes>)
131127
::: warning Important Notes
132128
- **String parameter is only for file paths**: If a string is passed, the function will calculate the hash value of that file
133129
- **Binary data must use bytes parameter**: To calculate the hash value of binary data, you must wrap the data with the `bytes()` function
134-
- **String data hashing**: To calculate the hash value of string data, please use `hash.strhash32`, `hash.strhash64`, or `hash.strhash128` interfaces
135130
:::
136131

137132
#### Usage
@@ -218,7 +213,6 @@ hash.xxhash32(input: <string|bytes>)
218213
::: warning Important Notes
219214
- **String parameter is only for file paths**: If a string is passed, the function will calculate the hash value of that file
220215
- **Binary data must use bytes parameter**: To calculate the hash value of binary data, you must wrap the data with the `bytes()` function
221-
- **String data hashing**: To calculate the hash value of string data, please use `hash.strhash32` interface
222216
:::
223217

224218
#### Usage
@@ -263,7 +257,6 @@ hash.xxhash64(input: <string|bytes>)
263257
::: warning Important Notes
264258
- **String parameter is only for file paths**: If a string is passed, the function will calculate the hash value of that file
265259
- **Binary data must use bytes parameter**: To calculate the hash value of binary data, you must wrap the data with the `bytes()` function
266-
- **String data hashing**: To calculate the hash value of string data, please use `hash.strhash64` interface
267260
:::
268261

269262
#### Usage
@@ -292,9 +285,7 @@ local checksum = hash.xxhash64(bytes("hello"))
292285
-- ❌ Wrong: Don't pass string data directly
293286
local key = hash.xxhash64(table.concat(params, "|"))
294287

295-
-- ✅ Correct: Use strhash64 interface to calculate string hash value
296-
local key = hash.strhash64(table.concat(params, "|"))
297-
-- Or use bytes wrapper
288+
-- ✅ Correct: Use bytes wrapper for binary data
298289
local key = hash.xxhash64(bytes(table.concat(params, "|")))
299290
```
300291

@@ -320,7 +311,6 @@ hash.xxhash128(input: <string|bytes>)
320311
::: warning Important Notes
321312
- **String parameter is only for file paths**: If a string is passed, the function will calculate the hash value of that file
322313
- **Binary data must use bytes parameter**: To calculate the hash value of binary data, you must wrap the data with the `bytes()` function
323-
- **String data hashing**: To calculate the hash value of string data, please use `hash.strhash128` interface
324314
:::
325315

326316
#### Usage

docs/zh/api/scripts/builtin-modules/hash.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ hash.md5(input: <string|bytes>)
2525
::: warning 重要提示
2626
- **string 参数只能作为文件路径传入**:如果传入的字符串是文件路径,函数会计算该文件的哈希值
2727
- **二进制数据必须使用 bytes 参数**:要计算二进制数据的哈希值,必须使用 `bytes()` 函数包装数据
28-
- **字符串数据的哈希计算**:如果要计算字符串数据的哈希值,请使用 `hash.strhash32``hash.strhash64``hash.strhash128` 接口
2928
- **常见错误**:如果文件不存在,函数会错误地将文件路径作为字符串数据来计算哈希值,且不会报错,导致结果不正确
3029
:::
3130

@@ -58,9 +57,7 @@ print("MD5: " .. checksum)
5857
-- ❌ 错误:如果 "hello" 不是文件路径,会错误地计算文件路径字符串的哈希值
5958
local checksum = hash.md5("hello")
6059

61-
-- ✅ 正确:使用 strhash 接口计算字符串哈希值
62-
local checksum = hash.strhash32("hello")
63-
-- 或者使用 bytes 包装
60+
-- ✅ 正确:使用 bytes 包装二进制数据
6461
local checksum = hash.md5(bytes("hello"))
6562
```
6663

@@ -86,7 +83,6 @@ hash.sha1(input: <string|bytes>)
8683
::: warning 重要提示
8784
- **string 参数只能作为文件路径传入**:如果传入的字符串是文件路径,函数会计算该文件的哈希值
8885
- **二进制数据必须使用 bytes 参数**:要计算二进制数据的哈希值,必须使用 `bytes()` 函数包装数据
89-
- **字符串数据的哈希计算**:如果要计算字符串数据的哈希值,请使用 `hash.strhash32``hash.strhash64``hash.strhash128` 接口
9086
:::
9187

9288
#### 用法说明
@@ -131,7 +127,6 @@ hash.sha256(input: <string|bytes>)
131127
::: warning 重要提示
132128
- **string 参数只能作为文件路径传入**:如果传入的字符串是文件路径,函数会计算该文件的哈希值
133129
- **二进制数据必须使用 bytes 参数**:要计算二进制数据的哈希值,必须使用 `bytes()` 函数包装数据
134-
- **字符串数据的哈希计算**:如果要计算字符串数据的哈希值,请使用 `hash.strhash32``hash.strhash64``hash.strhash128` 接口
135130
:::
136131

137132
#### 用法说明
@@ -214,7 +209,6 @@ hash.xxhash32(input: <string|bytes>)
214209
::: warning 重要提示
215210
- **string 参数只能作为文件路径传入**:如果传入的字符串是文件路径,函数会计算该文件的哈希值
216211
- **二进制数据必须使用 bytes 参数**:要计算二进制数据的哈希值,必须使用 `bytes()` 函数包装数据
217-
- **字符串数据的哈希计算**:如果要计算字符串数据的哈希值,请使用 `hash.strhash32` 接口
218212
:::
219213

220214
#### 用法说明
@@ -259,7 +253,6 @@ hash.xxhash64(input: <string|bytes>)
259253
::: warning 重要提示
260254
- **string 参数只能作为文件路径传入**:如果传入的字符串是文件路径,函数会计算该文件的哈希值
261255
- **二进制数据必须使用 bytes 参数**:要计算二进制数据的哈希值,必须使用 `bytes()` 函数包装数据
262-
- **字符串数据的哈希计算**:如果要计算字符串数据的哈希值,请使用 `hash.strhash64` 接口
263256
:::
264257

265258
#### 用法说明
@@ -288,9 +281,7 @@ local checksum = hash.xxhash64(bytes("hello"))
288281
-- ❌ 错误:不要直接传入字符串数据
289282
local key = hash.xxhash64(table.concat(params, "|"))
290283

291-
-- ✅ 正确:使用 strhash64 接口计算字符串哈希值
292-
local key = hash.strhash64(table.concat(params, "|"))
293-
-- 或者使用 bytes 包装
284+
-- ✅ 正确:使用 bytes 包装二进制数据
294285
local key = hash.xxhash64(bytes(table.concat(params, "|")))
295286
```
296287

@@ -316,7 +307,6 @@ hash.xxhash128(input: <string|bytes>)
316307
::: warning 重要提示
317308
- **string 参数只能作为文件路径传入**:如果传入的字符串是文件路径,函数会计算该文件的哈希值
318309
- **二进制数据必须使用 bytes 参数**:要计算二进制数据的哈希值,必须使用 `bytes()` 函数包装数据
319-
- **字符串数据的哈希计算**:如果要计算字符串数据的哈希值,请使用 `hash.strhash128` 接口
320310
:::
321311

322312
#### 用法说明

0 commit comments

Comments
 (0)