Communitygithub.com

資料加密技能

全面資料加密——TLS 無所不在,PII 使用 AES-256-GCM 加密,密碼使用 bcrypt,備份檔也加密。

資料加密技能 是什麼?

此技能提供一套完整的資料加密規範與實作準則,涵蓋傳輸層(TLS)、儲存層(AES-256-GCM)與密碼雜湊(bcrypt/argon2id)。它能協助開發者在應用程式中落實端到端資料保護,包含強制 HTTPS、使用 AES-256-GCM 加密個人識別資訊(PII)、以 SHA-256 雜湊電子郵件以便搜尋、並將密碼以專用雜湊演算法儲存。支援 Node.js 與瀏覽器端,並提供 AES-256-GCM 加密/解密的程式碼範例。此外,本技能強調加密金鑰應存放於機密管理服務而非程式碼中,並要求資料庫備份亦需加密,有效降低資料外洩風險。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/data-encryption

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

資料加密

規則

  • TLS 無所不在:將 HTTP 重新導向至 HTTPS、設定 HSTS 標頭,絕不允許未加密連線
  • 在應用程式層級以 AES-256-GCM 加密 PII 資料欄位,再存入資料庫
  • 電子郵件以 SHA-256 雜湊供查詢使用,以 AES-256-GCM 加密供顯示使用——在不會暴露資料的前提下支援搜尋
  • 密碼:僅使用 bcrypt 或 argon2id——絕不使用 SHA、MD5 或可逆加密
  • 加密資料庫備份,並將加密金鑰與資料分開存放
  • 瀏覽器端加密使用 crypto.subtle,伺服器端使用 node:crypto
  • 將加密金鑰存放於機密管理服務,切勿寫在程式碼中或與加密資料放在一起
// Node.js 中的 AES-256-GCM 加密/解密
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";

const ENCRYPTION_KEY = Buffer.from(process.env.ENCRYPTION_KEY!, "hex"); // 32 位元組

function encrypt(plaintext: string): string {
  const iv = randomBytes(12);
  const cipher = createCipheriv("aes-256-gcm", ENCRYPTION_KEY, iv);
  const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
  const tag = cipher.getAuthTag();
  return Buffer.concat([iv, tag, encrypted]).toString("base64");
}

function decrypt(ciphertext: string): string {
  const buf = Buffer.from(ciphertext, "base64");
  const iv = buf.subarray(0, 12);
  const tag = buf.subarray(12, 28);
  const encrypted = buf.subarray(28);
  const decipher = createDecipheriv("aes-256-gcm", ENCRYPTION_KEY, iv);
  decipher.setAuthTag(tag);
  return decipher.update(encrypted) + decipher.final("utf8");
}

應避免事項

  • 以明文儲存 PII——一次資料庫外洩就會暴露一切
  • 使用 ECB 模式或未經認證的 AES(無 HMAC 的 CBC)——請使用 GCM
  • 使用 MD5 或 SHA 進行密碼雜湊——它們並非密碼雜湊演算法
  • 在原始碼中硬編碼加密金鑰——請使用環境變數或 KMS
  • 透過 HTTP 傳送敏感資料,即使只在內部網路也一樣——所有連線都應使用 TLS

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Tenant isolation (row-level vs schema), subdomain routing, per-tenant config, and data partitioning.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

相關技能