I know about ObjectId how it works internally and its bytes occupation from both docs: bson-types/#objectid and method-ObjectId,
Is it possible to decript like below without using any mongodb functions?
const ObjectID = require("mongodb").ObjectID;
var id = new ObjectID().toString(), ctr = 0;
var timestamp = id.slice(ctr, (ctr+=8));
var machineID = id.slice(ctr, (ctr+=6));
var processID = id.slice(ctr, (ctr+=4));
var counter = id.slice(ctr, (ctr+=6));
console.log("id:", id);
console.log("timestamp:", timestamp);
console.log("machineID:", machineID);
console.log("processID:", processID);
console.log("counter:", counter);
Result:
id: 607c3511f6c1fb54f91046da
timestamp: 607c3511
machineID: f6c1fb
processID: 54f9
counter: 1046da
And convert that parts in Integer:
console.log("timestamp:", parseInt(timestamp, 16));
console.log("machineID:", parseInt(machineID, 16));
console.log("processID:", parseInt(processID, 16));
console.log("counter:", parseInt(counter, 16));
Result:
timestamp: 1618752785
machineID: 16171515
processID: 21753
counter: 1066714
I am sure this is not a valid process to decript objectID, please suggest is there any way to get accurate partition?