Peer Id generator and operator, designed with circular Id namespaces in mind, used in
webrtc-explorer. Currently only supports 48 bits, but I'm happy to make accept PR that make it Id size agnostic.
This work was developed by David Dias with supervision by Luís Veiga, all in INESC-ID Lisboa (Distributed Systems Group), Instituto Superior Técnico, Universidade de Lisboa, with the support of Fundação para a Ciência e Tecnologia.
More info on the team's work at:
If you use this project, please acknowledge it in your work by referencing the following document:
David Dias and Luís Veiga. browserCloud.js A federated community cloud served by a P2P overlay network on top of the web platform. INESC-ID Tec. Rep. 14/2015, Apr. 2015
var Id = require('dht-id);var idA = new Id(); // generates a new random Id with 48 bits lengthvar idB = new Id(<value to generate the Id from>); // generates an Id based on the value, same value always generates same IdidA.toHex(); // returns the hex value of the Id in a stringidA.toDec(); // returns the dec value of the Id in a numberidA.next(); // basically this id + 1, useful to send to SucessorId.hash(content); // convinient way to find the Id of a content and guarantee that it has our ideal id length