Skip to content

JavaScript library for calculating context triggered piecewise hash(CTPH, also called fuzzy hashing).

License

Notifications You must be signed in to change notification settings

huwenshuo/ctph.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The ctph.js

JavaScript library for calculating context triggered piecewise hash(CTPH, also called fuzzy hashing). CTPH can be used to identify similar or almost identical content(text,img,etc.), the library can works both on NodeJS and browser.

More information about CTPH: Identifying almost identical files using context triggered piecewise hashing

Install

npm install ctph.js

Example

var ctph = require('ctph.js');

var str1 = "Java is a computer programming language, Not to be confused with JavaScript.";
var str2 = "JavaScript is a computer programming language, Not to be confused with Java.";

var d1 = ctph.digest(str1);
var d2 = ctph.digest(str2);
var similarity = ctph.similarity(d1, d2);// 75

var crypto = require('crypto');
var rd1 = ctph.digest(crypto.randomBytes(4096));
var rd2 = ctph.digest(crypto.randomBytes(4096));
var rsimilarity = ctph.similarity(rd1, rd2); //nears 0

License

MIT

About

JavaScript library for calculating context triggered piecewise hash(CTPH, also called fuzzy hashing).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published