How to use the concat function from safe-buffer

Find comprehensive JavaScript safe-buffer.concat code examples handpicked from public code repositorys.

369
370
371
372
373
374
375
376
377
378
function routingInfoEncoder (datas) {
  let buffer = Buffer.from([])
  datas.forEach(data => {
    buffer = Buffer.concat([buffer, hexToBuffer(data.pubkey)])
    buffer = Buffer.concat([buffer, hexToBuffer(data.short_channel_id)])
    buffer = Buffer.concat([buffer, Buffer.from([0, 0, 0].concat(intBEToWords(data.fee_base_msat, 8)).slice(-4))])
    buffer = Buffer.concat([buffer, Buffer.from([0, 0, 0].concat(intBEToWords(data.fee_proportional_millionths, 8)).slice(-4))])
    buffer = Buffer.concat([buffer, Buffer.from([0].concat(intBEToWords(data.cltv_expiry_delta, 8)).slice(-2))])
  })
  return hexToWord(buffer)
fork icon54
star icon78
watch icon12

+ 7 other calls in file

16
17
18
19
20
21
22
23
24
25
  if (signType !== 'dsa') throw new Error('wrong private key type')
  return dsaSign(hash, priv, hashType)
} else {
  if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
}
hash = Buffer.concat([tag, hash])
var len = priv.modulus.byteLength()
var pad = [0, 1]
while (hash.length + pad.length + 1 < len) pad.push(0xff)
pad.push(0x00)
fork icon30
star icon29
watch icon7

+ 55 other calls in file

76
77
78
79
80
81
82
83
84
85
const encryptionKey = hash.slice(0, 32);
const macKey = hash.slice(32);
const ciphertext = AES256CbcEncrypt(iv, encryptionKey, plaintext);
const dataToMac = Buffer.concat([iv, ephemPubKeyEncoded, ciphertext]);
const mac = Crypto.createHmac("sha256", macKey).update(dataToMac).digest();
const serializedCiphertext = Buffer.concat([
  iv, // 16 bytes
  ephemPubKeyEncoded, // 65 bytes
  mac, // 32 bytes
  ciphertext,
fork icon16
star icon36
watch icon1

+ 11 other calls in file

20
21
22
23
24
25
26
27
28
  } else {
    input = toBuffer(input)
    if (input.length === 1 && input[0] < 128) {
      return input
    } else {
      return Buffer.concat([encodeLength(input.length, 128), input])
    }
  }
}
fork icon15
star icon32
watch icon15

+ 23 other calls in file

107
108
109
110
111
112
113
114
115
116
117
  }
  this.state = fromArray(Zi)
}


GHASH.prototype.update = function (buf) {
  this.cache = Buffer.concat([this.cache, buf])
  var chunk
  while (this.cache.length >= 16) {
    chunk = this.cache.slice(0, 16)
    this.cache = this.cache.slice(16)
fork icon25
star icon56
watch icon0

26
27
28
29
30
31
32
33
34
    throw new Error(msg || 'Assertion failed');
  }
}

function decipherBuffer(decipher, data) {
  return Buffer.concat([decipher.update(data), decipher.final()]);
}

var Thirdparty = {};
fork icon9
star icon14
watch icon9

+ 31 other calls in file

9
10
11
12
13
14
15
16
17
18
  return EOS_PUBLIC_PREFIX.concat(base58.encode(pubBuf));
}

function bufferToPrivate(privBuf) {
  const EOS_PRIVATE_PREFIX = "80";
  privBuf = Buffer.concat([Buffer.from(EOS_PRIVATE_PREFIX, "hex"), privBuf]);
  let tmp = new createHash("sha256").update(privBuf).digest();
  let checksum = new createHash("sha256").update(tmp).digest("hex").slice(0, 8);
  privBuf = Buffer.concat([privBuf, Buffer.from(checksum, "hex")]);
  return base58.encode(privBuf);
fork icon0
star icon2
watch icon0

+ 5 other calls in file

3
4
5
6
7
8
9
10
11
12
const curve = ecurve.getCurveByName('secp256k1');
const math = require('./math');
const check = require('./check');
const convert = require('./convert');

const concat = Buffer.concat;
const G = curve.G;
const p = curve.p;
const n = curve.n;
const zero = BigInteger.ZERO;
fork icon25
star icon0
watch icon0

1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
  return
}

if (bufferLength) {
  debug('has body', self.uri.href, bufferLength)
  response.body = Buffer.concat(buffers, bufferLength)
  if (self.encoding !== null) {
    response.body = response.body.toString(self.encoding)
  }
  // `buffer` is defined in the parent scope and used in a closure it exists for the life of the Request.
fork icon0
star icon0
watch icon1

+ 6 other calls in file

43
44
45
46
47
48
49
50
51
52
    }
    buffers.push(buffer)
  }
}

this[BUFFER] = Buffer.concat(buffers)

let type = options && options.type !== undefined && String(options.type).toLowerCase()
if (type && !/[^\u0020-\u007E]/.test(type)) {
  this[TYPE] = type
fork icon0
star icon0
watch icon2

+ 13 other calls in file

207
208
209
210
211
212
213
214
215
216
217
    return '';
  }
  if (isUrl) {
    return toBuffer('<link rel="stylesheet" href="' + css + '" />', charset);
  }
  return Buffer.concat([STYLE_START, toBuffer(css, charset), STYLE_END]);
}


function evalJson(str) {
  try {
fork icon0
star icon0
watch icon1

+ 26 other calls in file

1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
    socket._remotePort;
  var tunnelData = getTunnelData(socket, clientIp, clientPort);
  if (tunnelData) {
    statusLine += '\r\n' + config.TEMP_TUNNEL_DATA_HEADER + ': ' + encodeURIComponent(JSON.stringify(tunnelData));
  }
  return Buffer.concat([Buffer.from(statusLine), chunk]);
}


module.exports = function (socket, next, isWebPort) {
  var reqSocket, reqDestroyed, resDestroyed;
fork icon0
star icon0
watch icon1

+ 8 other calls in file

128
129
130
131
132
133
134
135
136
137
  }
  callback(reader, null, size);
};

reader.on('data', function (data) {
  buffer = buffer ? Buffer.concat([buffer, data]) : data;
  if (HEADERS_SEP_RE.test(buffer + '')) {
    response(null, RegExp.$1);
  } else if (buffer.length > MAX_HEADERS_SIZE) {
    response();
fork icon0
star icon0
watch icon1

+ 3 other calls in file

5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
		output.push(chunk)
	})


	decoder.end(input)


	return Buffer.concat(output)
}


exports.LZ4_uncompress = LZ4_uncompress
}).call(this,require("buffer").Buffer)
fork icon0
star icon0
watch icon1

+ 9 other calls in file