---
title: hash – ฟังก์ชันเข้ารหัส String
url: https://www.thepexcel.com/functions/n8n/string-functions/hash-n8n/
type: function-explainer
program: n8n
syntax: hash(text)
date: 2025-12-16
updated: 2025-12-17
scores:
  popularity: 6
  difficulty: 4
  usefulness: 6
---

# hash – ฟังก์ชันเข้ารหัส String

> แปลง string เป็น hash value

## คำอธิบาย

hash แปลง string เป็น hash code ที่ไม่สามารถแปลงกลับได้ ฟังก์ชันนี้มีประโยชน์ในการเข้ารหัสข้อมูล สร้าง unique IDs หรือตรวจสอบความเท่ากันของข้อมูล

## Syntax

```excel
hash(text)
```

**Variant**

```excel
$json.password.hash()
```

ใช้เป็น method เมื่อ $json.password เป็น string

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| text | Yes | string |  | ข้อความที่ต้องการเข้ารหัส |

## เคสการใช้งาน

### เข้ารหัสรหัสผ่าน

แปลงรหัสผ่านเป็น hash เพื่อบันทึกในฐานข้อมูล

_เหมาะกับ:_ password-hashing

### สร้าง Unique ID

สร้าง unique identifier จากข้อมูล

_เหมาะกับ:_ id-generation

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: เข้ารหัส String

```excel
{{ hash('hello world') }}
```

**ผลลัพธ์:** `5eb63bbbe01eeed093cb22bb8f5acdc3`

ฟังก์ชันแปลง 'hello world' เป็น hash value

### 2. ตัวอย่างที่ 2: เข้ารหัสรหัสผ่าน

```excel
{{ hash($json.password) }}
```

**ผลลัพธ์:** `abc123def456...`

สูตรนี้เข้ารหัสรหัสผ่านสำหรับบันทึก

### 3. ตัวอย่างที่ 3: สร้าง Unique ID

```excel
{{ hash($json.email + Date.now()) }}
```

**ผลลัพธ์:** `f8c3c5f8e1e3...`

สร้าง unique hash จากอีเมลและเวลาปัจจุบัน

## หมายเหตุเพิ่มเติม

⚠️ ฟังก์ชัน hash() ใช้สำหรับการเข้ารหัส ไม่ใช่เพื่อความปลอดภัยสูงสุด ใช้ร่วมกับ salt สำหรับการเข้ารหัสรหัสผ่าน

## คำถามที่พบบ่อย

**Q: hash() จะแปลง hash กลับเป็น string ได้หรือไม่?**

ไม่ได้ hash เป็นทางเดียว ไม่สามารถแปลงกลับได้ เนื่องจากมีการสูญเสียข้อมูล

**Q: hash() ใช้ algorithm ใด?**

โดยปกติ hash() ใช้ MD5 หรือ SHA algorithms ขึ้นอยู่กับการตั้งค่า n8n

**Q: ใช้ hash() เมื่อไหร่ในการทำงาน?**

ใช้เมื่อต้องการเข้ารหัสข้อมูล สร้าง unique IDs หรือตรวจสอบความสมบูรณ์

## ฟังก์ชันที่เกี่ยวข้อง

- base64-decode-n8n
- base64-encode-n8n
- [unique – ลบค่าซ้ำออกจากอาร์เรย์](https://www.thepexcel.com/functions/n8n/array-functions/unique-n8n/)

---

_Source: [https://www.thepexcel.com/functions/n8n/string-functions/hash-n8n/](https://www.thepexcel.com/functions/n8n/string-functions/hash-n8n/)_
