Communitygithub.com

YepAPI/技能

数据加密 — 全面实施 TLS,对 PII 使用 AES-256-GCM 加密,密码采用 bcrypt 算法,备份数据加密存储。

技能 是什么?

该技能为 AI 代理(如 Claude Code、Cursor、Codex)提供了一套全面的数据加密规则和实现指南,旨在保护应用程序中的敏感数据。它覆盖了传输层(TLS)、存储层(AES-256-GCM)和身份验证(bcrypt/argon2id)三大安全领域。技能指导代理如何通过重定向 HTTP 到 HTTPS 并设置 HSTS 头来强制全站 TLS,使用 AES-256-GCM 对个人身份信息(PII)列进行应用层加密,以及使用 bcrypt 或 argon2id 安全哈希密码。它还提供了使用 `node:crypto` 在 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(CBC 无 HMAC)—— 请使用 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.

相关技能