How to use the long.Long.fromBits function in long

To help you get started, we’ve selected a few long 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 christkv / node-pure-crypto / lib / symmetric / block / seed.js View on Github external
var createKey = function(key, decrypt) {
  var key01 = Long.fromBits(util.decodeUInt32(key, 4), util.decodeUInt32(key, 0));
  var key23 = Long.fromBits(util.decodeUInt32(key, 12), util.decodeUInt32(key, 8));
  
  // var k = this.key = new Array(32);
  var k = new Array(32);
  var index = 0; 
  var kInc = 2; 
  
  if(decrypt) {
    index = index + 30;
    kInc = 0 - kInc;
  }
  
  // Mix up the key
  for(var i = 0; i < ROUNDS; i++) {
    var t0 = Long.fromNumber(key01.shiftRightUnsigned(32).getLowBitsUnsigned()
      + key23.shiftRightUnsigned(32).getLowBitsUnsigned()
      - s_kc[i]).getLowBitsUnsigned();
github christkv / node-pure-crypto / lib / hash / whirlpool.js View on Github external
var processFilledBuffer = function(self, src, inOff) {
  // copies into the block...
  for(var i = 0; i < self._state.length; i++) {
    self._block[i] = Long.fromBits(util.decodeUInt32(self._buffer, (i * 8) + 4), util.decodeUInt32(self._buffer, (i * 8)));
  }

  processBlock(self);
  self._bufferPos = 0;
  for(var i = 0; i < self._buffer.length; i++) self._buffer[i] = 0;
}
github christkv / node-pure-crypto / lib / symmetric / block / seed.js View on Github external
var createKey = function(key, decrypt) {
  var key01 = Long.fromBits(util.decodeUInt32(key, 4), util.decodeUInt32(key, 0));
  var key23 = Long.fromBits(util.decodeUInt32(key, 12), util.decodeUInt32(key, 8));
  
  // var k = this.key = new Array(32);
  var k = new Array(32);
  var index = 0; 
  var kInc = 2; 
  
  if(decrypt) {
    index = index + 30;
    kInc = 0 - kInc;
  }
  
  // Mix up the key
  for(var i = 0; i < ROUNDS; i++) {
    var t0 = Long.fromNumber(key01.shiftRightUnsigned(32).getLowBitsUnsigned()
      + key23.shiftRightUnsigned(32).getLowBitsUnsigned()
github christkv / node-pure-crypto / lib / hash / whirlpool.js View on Github external
var packIntoLong = function(b7, b6, b5, b4, b3, b2, b1, b0) {
  return Long.fromBits(util.decodeUInt32R([b0, b1, b2, b3], 0), util.decodeUInt32R([b4, b5, b6, b7], 0));
}
github christkv / node-pure-crypto / lib / hash / sha384.js View on Github external
SHA384.prototype.processWord = function(src, inOff) {
  this.W[this.wOff] = Long.fromBits(util.decodeUInt32(src, inOff + 4), util.decodeUInt32(src, inOff + 0));
  if (++this.wOff == 16) {
    this.processBlock();
  }
}
github christkv / node-pure-crypto / lib / hash / skein.js View on Github external
var inputBufferToCipherInput = function(self) {
  for(var i = 0; i < self.cipherStateWords; i++) {
    self.cipherInput[i] = Long.fromBits(util.decodeUInt32R(self.inputBuffer, (i * 8) + 0), util.decodeUInt32R(self.inputBuffer, (i * 8) + 4));
  }  
}
github christkv / node-pure-crypto / lib / hash / tiger.js View on Github external
Tiger.prototype.processWord = function(src, inOff) {
  this.x[this.xOff++] = Long.fromBits(util.decodeUInt32R(src, inOff + 0), util.decodeUInt32R(src, inOff + 4));
  if (this.xOff == this.x.length) {
    this.processBlock();
  }

  this.bOff = Long.ZERO;
}
github christkv / node-pure-crypto / lib / hash / sha512.js View on Github external
SHA512.prototype.processWord = function(src, inOff) {
  this.W[this.wOff] = Long.fromBits(util.decodeUInt32(src, inOff + 4), util.decodeUInt32(src, inOff + 0));
  if (++this.wOff == 16) {
    this.processBlock();
  }
}