skills-experimental/djb2-hash-pattern/SKILL.md
# djb2 Hash Pattern Skill djb2 Hash Pattern - djb2Hash function + signed 32-bit int + hash << 5 - hash + charCode | 0 + fast non-cryptographic + deterministic cross-runtime + Bun.hash fallback + hashContent + hashPair seed-chain + wyhash vs SHA-256。 ## 功能概述 从Claude Code的utils/hash.ts提取的djb2 hash模式,用于OpenClaw的快速哈希计算。 ## 核心机制 ### djb2Hash Function ```typescript export function djb2Hash(str: string): number { let hash = 0 for (let i = 0; i < str.length; i++) { hash = ((hash << 5) - ha
npx skillsauth add bianhaifeng789-hue/openclaw-config skills-experimental/djb2-hash-patternInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
djb2 Hash Pattern - djb2Hash function + signed 32-bit int + hash << 5 - hash + charCode | 0 + fast non-cryptographic + deterministic cross-runtime + Bun.hash fallback + hashContent + hashPair seed-chain + wyhash vs SHA-256。
从Claude Code的utils/hash.ts提取的djb2 hash模式,用于OpenClaw的快速哈希计算。
export function djb2Hash(str: string): number {
let hash = 0
for (let i = 0; i < str.length; i++) {
hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0
}
return hash
}
// djb2 string hash
# Signed 32-bit int
# Fast non-cryptographic
| 0 // Convert to signed 32-bit integer
// JavaScript bitwise OR coerces to 32-bit signed int
# Prevents overflow
# Deterministic across runtimes
hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0
// hash * 33 + charCode (equivalent to << 5 - hash)
# djb2 algorithm
# Daniel J. Bernstein hash
// djb2 string hash — fast non-cryptographic hash returning a signed 32-bit int.
// ~100x faster than SHA-256
// Not crypto-safe (collision-prone)
# Speed over security
// Deterministic across runtimes (unlike Bun.hash which uses wyhash)
// Use as a fallback when Bun.hash isn't available
// Or when you need on-disk-stable output (e.g. cache directory names)
// Same hash across Bun, Node, browsers
# On-disk-stable
export function hashContent(content: string): string {
if (typeof Bun !== 'undefined') {
return Bun.hash(content).toString() // ~100x faster
}
const crypto = require('crypto')
return crypto.createHash('sha256').update(content).digest('hex') // Fallback
}
// Bun.hash ~100x faster than SHA-256
# Node fallback to SHA-256
// Hash arbitrary content for change detection
// Bun.hash is ~100x faster than sha256
// Collision-resistant enough for diff detection (not crypto-safe)
// For diff/change detection
# Not crypto-safe
export function hashPair(a: string, b: string): string {
if (typeof Bun !== 'undefined') {
return Bun.hash(b, Bun.hash(a)).toString() // Seed-chain
}
const crypto = require('crypto')
return crypto
.createHash('sha256')
.update(a)
.update('\0') // Separator for Node
.update(b)
.digest('hex')
}
// Bun: seed-chain wyhash
# Node: incremental SHA-256 with separator
// Bun.hash uses wyhash (fast)
// Node uses SHA-256 (slow but standard)
// wyhash: ~100x faster than SHA-256
// SHA-256: crypto-safe (but slower)
# Bun: wyhash fast
# Node: SHA-256 safe
// Bun path seed-chains wyhash (hash(a) feeds as seed to hash(b))
// Naturally disambiguates ("ts","code") vs ("tsc","ode")
// No separator needed under Bun
// Seed-chain disambiguates
# No separator
// Node path uses incremental SHA-256 update
// .update('\0') separator needed
// Separator prevents collisions
# '\0' separator for Node
{
"djb2Hash": 1234567890,
"hashContent": "abc123",
"runtime": "bun"
}
hash << 5 - hash + charCode | 0 → hash * 33 + char → signed 32-bit → fast non-crypto
# djb2算法
# hash * 33 + charCode
# | 0转signed 32-bit
djb2Hash: same result in Bun/Node/Browser | Bun.hash: wyhash runtime-specific
# djb2跨runtime确定性
# Bun.hash使用wyhash(runtime-specific)
Bun.hash(content) → wyhash → ~100x faster than SHA-256 → change detection
# Bun.hash快100倍
# wyhash算法
# change detection用途
Bun.hash(b, Bun.hash(a)) → seed-chain → ("ts","code") ≠ ("tsc","ode") → no separator
# Bun seed-chain disambiguates
# 无需separator
# wyhash特性
Node: update('\0') separator | Bun: seed-chain no separator → different handling
# Node需要separator
# Bun不需要
# 不同处理方式
utils/hash.ts (46 lines)business
IAA 日报飞书输出能力。 支持把固定 CSV 模板一键转换成: - 中文运营结论 - 飞书卡片 JSON - 飞书发送载荷 Use when: - 需要把 IAA 日报直接发到飞书 - 需要从 CSV 一键生成运营日报
data-ai
IAA日报分析模型 功能: - 渠道日报自动分析 - 小时级+日级ROI联动判断 - 按地区输出加量/降量/停投建议 - 按产品类型输出阈值 - 自动识别利润区/观察区/止损区 Use when: - 分析每天投放数据 - 生成运营日报结论 - 判断是否加量/降量/停投 - 对比美加澳/日韩表现 Keywords: - 日报模型, 投放日报, 加量, 降量, 停投, ROI日报, 分地区分析
data-ai
IAA固定日报分析模板 功能: - 固定字段模板(可直接贴每天数据) - 自动输出总盘结论 - 自动输出美加澳/日韩结论 - 自动给出加量/降量/停投建议 - 适配文件修复/清理两类产品 Use when: - 需要固定日报格式 - 每天复盘渠道表现 - 给运营团队出统一结论 Keywords: - 固定模板, 日报模板, ROI模板, IAA日报, 运营模板
development
# HyperlinkPool Pattern Skill HyperlinkPool Pattern - HyperlinkPool class + strings array + stringMap + Index 0 no hyperlink + intern(hyperlink) + get(id) + undefined handling + 5-minute reset + OSC8 hyperlink interning。 ## 功能概述 从Claude Code的ink/screen.ts提取的HyperlinkPool模式,用于OpenClaw的OSC8超链接池管理。 ## 核心机制 ### HyperlinkPool Class ```typescript export class HyperlinkPool { private strings: string[] = [''] // Index 0 = no hyperlink private stringMap = new Map<string, number>() // strings