What kind of function is used when hashing in TW

33 views
Skip to first unread message

Jan

unread,
Sep 19, 2020, 4:50:34 PM9/19/20
to TiddlyWiki
Hi Tiddlydevs,
Thomas Elminger in his hashmacro uses a tw.utils-hash function:
var hash = $tw.utils.hashString(str);
What kind of hash-function does TW use there? How would you enter it in php to reproduce the identical value for the same str serverside.

Thanks for your help!
Best wishes Jan

Mark S.

unread,
Sep 19, 2020, 5:55:06 PM9/19/20
to TiddlyWiki
exports.hashString = function(str) {
	return str.split("").reduce(function(a,b) {
		a = ((a << 5) - a) + b.charCodeAt(0);
		return a & a;
	},0);
};
Reply all
Reply to author
Forward
0 new messages