Sunday 15 January 2012

javascript - Convert a decimal number represented as a string to its hex format still representing it as a string -



javascript - Convert a decimal number represented as a string to its hex format still representing it as a string -

i'm trying operations in 160 bit integers using biginteger.js library, want maintain representation of in hex format can transmit them on , utilize them id.

var git_sha1 = require('git-sha1'); var bigint = require("big-integer"); var uuid = git_sha1((~~(math.random() * 1e9)).tostring(36) + date.now()); console.log('in hex \t', uuid); // see uuid have console.log('in dec \t', bigint(uuid, 16).tostring()); // convert bigint , represent string console.log('to hex \t', bigint(uuid, 16).tostring(16)); // seek convert hex

here output:

in hex 4044654fce69424a651af2825b37124c25094658 in dec 366900685503779409298642816707647664013657589336 hex 366900685503779409298642816707647664013657589336

i need to hex same in hex. suggestions? give thanks you!

this fixed pr of https://github.com/peterolson/biginteger.js/pull/18

javascript node.js sha1 biginteger

No comments:

Post a Comment