How to use the Buffer function from safe-buffer

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

2
3
4
5
6
7
8
9
10
11
function oldBrowser () {
  throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
}
var safeBuffer = require('safe-buffer')
var randombytes = require('randombytes')
var Buffer = safeBuffer.Buffer
var kBufferMaxLength = safeBuffer.kMaxLength
var crypto = global.crypto || global.msCrypto
var kMaxUint32 = Math.pow(2, 32) - 1
function assertOffset (offset, length) {
fork icon5
star icon9
watch icon0

+ 3 other calls in file

106
107
108
109
110
111
112
113
114
115
if (opts.heartbeats) {
  // start ping/pong heartbeats
  heartbeats(socket)
}
// use the http basic auth as ID
let rawID = _.has(headers, 'authorization') ? new Buffer(
  headers.authorization.replace('Basic ', ''),
  'base64'
).toString() : UUID()
let ID = makeSHA(rawID)
fork icon3
star icon2
watch icon3