javascript - memset and sprintf equivalent in Node.JS -



javascript - memset and sprintf equivalent in Node.JS -

i trying port code node.js

void init(int a, int b, int internalrounds) { memset(nkey, 0x00, 256); sprintf((char*)nkey, "%.5d_xxxxx%.5d_masin_%.5d", (a+10), (b+10), (a+b)); setup(nkey, 256); ucprev = getrandom(); }

i want know how properly.

i have:

var crypt = function(a, b, internalrounds) { var nkey = new buffer(256) nkey.fill(0x00) nkey = util.format('%.5d_xxxxx%.5d_masin_%.5d', (a+10), (b+10), (a+b)) this.setup(nkey, 256) this.ucprev = this.getrandom() }

i understand if did correctly

util.format doesn’t back upwards precision (i.e. %.5f). in addition, assigning nkey replacing buffer string returned util.format. want write string buffer instead.

here’s how might prepare issues:

var key = new buffer(256); key.fill(0); key.write( (a + 10).tofixed(5) + '_xxxxx' + (b + 10).tofixed(5) + '_masin_' + (a + b).tofixed(5) );

javascript c node.js

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -