How to use the cabal-core.protocolVersion function in cabal-core

To help you get started, we’ve selected a few cabal-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fenwick67 / cabal-clone / lib / common / cabal-key-for-string.js View on Github external
// empty string / null => random new key
	if (!str){
		return randomKey();
	}

	// was passed an actual cabal://123abc key or just 64 chars that are all hex
	var edKey = str.toLowerCase().replace(/cabal:\/\/|[^\w\d]/ig,'');
	var strippedKey = edKey.replace(/[^a-f0-9]/ig,'');
	if (edKey.length == 64 && strippedKey.length == 64){
		return edKey;
	}

	// generate one based on string input
	return shajs('sha256')
		.update('cabal-clonev0:'+cabalCore.protocolVersion+':'+str,'utf8')
		.digest('hex');
}

cabal-core

p2p db functions for chat

AGPL-3.0
Latest version published 1 year ago

Package Health Score

49 / 100
Full package analysis