PHP WebShell
Текущая директория: /opt/BitGoJS/node_modules/cids/node_modules/multicodec/src
Просмотр файла: util.js
'use strict'
const varint = require('varint')
const { Buffer } = require('buffer')
module.exports = {
numberToBuffer,
bufferToNumber,
varintBufferEncode,
varintBufferDecode,
varintEncode
}
function bufferToNumber (buf) {
return parseInt(buf.toString('hex'), 16)
}
function numberToBuffer (num) {
let hexString = num.toString(16)
if (hexString.length % 2 === 1) {
hexString = '0' + hexString
}
return Buffer.from(hexString, 'hex')
}
function varintBufferEncode (input) {
return Buffer.from(varint.encode(bufferToNumber(input)))
}
function varintBufferDecode (input) {
return numberToBuffer(varint.decode(input))
}
function varintEncode (num) {
return Buffer.from(varint.encode(num))
}
Выполнить команду
Для локальной разработки. Не используйте в интернете!