Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static stringToBuffer (str, encryption) {
let strLength = Buffer.byteLength(str, encryption)
let lengthBuffer = BufferAlloc(lengthSize)
lengthBuffer.writeInt8(strLength)
let strBuffer = BufferAlloc(strLength)
strBuffer.write(str, 0, strLength, encryption)
return Buffer.concat([lengthBuffer, strBuffer])
}
getBuffer () {
let bufferArray = []
let mainEventBuffer = BufferAlloc(1)
mainEventBuffer.writeInt8(+this.mainEvent)
bufferArray.push(mainEventBuffer)
let typeBuffer = BufferAlloc(1)
typeBuffer.writeInt8(this.type)
bufferArray.push(typeBuffer)
let idBuffer = Envelop.stringToBuffer(this.id.toString(), 'hex')
bufferArray.push(idBuffer)
let ownerBuffer = Envelop.stringToBuffer(this.owner.toString(), 'utf-8')
bufferArray.push(ownerBuffer)
let recipientBuffer = Envelop.stringToBuffer(this.recipient.toString(), 'utf-8')
bufferArray.push(recipientBuffer)
let tagBuffer = Envelop.stringToBuffer(this.tag.toString(), 'utf-8')
bufferArray.push(tagBuffer)
if (this.data) {
static stringToBuffer (str, encryption) {
let strLength = Buffer.byteLength(str, encryption)
let lengthBuffer = BufferAlloc(lengthSize)
lengthBuffer.writeInt8(strLength)
let strBuffer = BufferAlloc(strLength)
strBuffer.write(str, 0, strLength, encryption)
return Buffer.concat([lengthBuffer, strBuffer])
}
getBuffer () {
let bufferArray = []
let mainEventBuffer = BufferAlloc(1)
mainEventBuffer.writeInt8(+this.mainEvent)
bufferArray.push(mainEventBuffer)
let typeBuffer = BufferAlloc(1)
typeBuffer.writeInt8(this.type)
bufferArray.push(typeBuffer)
let idBuffer = Envelop.stringToBuffer(this.id.toString(), 'hex')
bufferArray.push(idBuffer)
let ownerBuffer = Envelop.stringToBuffer(this.owner.toString(), 'utf-8')
bufferArray.push(ownerBuffer)
let recipientBuffer = Envelop.stringToBuffer(this.recipient.toString(), 'utf-8')
bufferArray.push(recipientBuffer)