Communitygithub.com

YepAPI/スキル

データ暗号化 — すべての通信にTLS、PIIにはAES-256-GCM、パスワードにはbcrypt、バックアップの暗号化。

スキル とは?

このスキルは、アプリケーション全体でデータ暗号化のベストプラクティスを強制するための詳細なルールと実装ガイドラインを提供します。Node.js環境におけるAES-256-GCMを使用した暗号化・復号の実用的なコード例を示し、TLSの強制、PII(個人識別情報)の暗号化、パスワードの安全なハッシュ化、データベースバックアップの保護をカバーします。暗号鍵をコードや暗号化データと一緒に保存せず、秘密管理サービスに保管する重要性を強調し、ECBモードや認証なしの暗号、MD5/SHAによるパスワードハッシュといった脆弱な方式を明確に避けるべきとしています。Claude CodeやCursorなどのAIエージェントに実装ルールとして読み込ませることで、安全な暗号化の実装を自動的に支援します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/data-encryption

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

データ暗号化

ルール

  • すべての通信にTLS:HTTPをHTTPSにリダイレクトし、HSTSヘッダーを設定し、暗号化されていない接続を許可しない
  • PIIカラムはアプリケーションレベルでAES-256-GCMにより暗号化してからデータベースに保存する
  • メールアドレスは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.

関連スキル