Structure-aware and layout-aware perceptual hashing for HTML and DOM content.
sha256
, murmur3
, blake3
, simhash
, minhash
npm install @iocium/domhash
npx domhash <input> [options]
Option | Description |
---|---|
--algo <type> |
Choose hashing algorithm |
--include <attrs> |
Comma-separated list of attributes to include |
--shape |
Output tag shape vector |
--layoutAware |
Enable layout-based canonicalization |
--resilience |
Output a resilience score |
--compare <input> |
Compare against another HTML or URL |
--diff |
Show structural diff |
--output <type> |
Output format: json , markdown , html |
import { domhash, computeResilienceScore, compareStructures } from '@iocium/domhash';
const result = await domhash('<form><input></form>', {
layoutAware: true,
resilience: true,
shapeVector: true,
includeAttributes: ['action']
});
console.log(result.hash); // structure hash
console.log(result.layoutHash); // layout-aware hash
console.log(result.resilienceScore); // between 0 and 1
console.log(result.shape); // tag structure vector
### DOM Hash Comparison Report
- SHA A: `abc123`
- SHA B: `def456`
- Structural Similarity: `91.25%`
- Shape Similarity: `88.00%`
**Structural Diff:**
```diff
- <p></p>
+ <span></span>
MIT License — see LICENSE for full terms.
Made with 💙 by iocium