Socket
Socket
Sign inDemoInstall

@sec-block/secjs-rlp

Package Overview
Dependencies
2
Maintainers
7
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @sec-block/secjs-rlp

secjs blockchain rlp lib


Version published
Weekly downloads
3
decreased by-76.92%
Maintainers
7
Install size
31.8 kB
Created
Weekly downloads
 

Readme

Source

JavaScript Style Guide

[JavaScript Style Guide]


SECRlpEncode

This package is used for SEC blockchain rlp encoding.

  • SECRlpEncode
    • new SECRlpEncode(config)
    • .encode(input, buffer, offset)Buffer
    • .decode(input, start, end)Array
    • .getLength(input)Number

new SECRlpEncode(config)

new SECRlpEncode(config) Constructs a rlp encode class.

ParamTypeDescription
configTBDTBD, will be implemented in the future

Example

const RLP = require('encode.js')

const rlp = new RLP()

SECRlpEncode.encode(input, buffer, offset) ⇒ Buffer

Returns input in RLP encoded format

ParamTypeDescription
input{Buffer, String, Integer, Array}Input data for RLP encode
buffer{Buffer}Input buffer which is in RLP encoded format
offset{Buffer}Buffer offset position

SECRlpEncode.decode(input, start, end) ⇒ Array

RLP decode for input data

ParamTypeDescription
input{Buffer, String, Integer, Array}Input should be in RLP encoded structure
start{Integer}"input" data array starting index
end{Integer}"input" data array ending index

SECRlpEncode.getLength(input) ⇒ Number

Returns input's length according to the first several indication bytes

ParamTypeDescription
input{Buffer, String, Integer, Array}Input should be in RLP encoded data, or the returned length is wrong

中文简介:

本库函数用于SEC区块链的RLP编码 RLP编码用于存储和传输数据,处理数据则用.json格式文件 json文件由RLP编码过以后,由于json文件的键值被去掉了,仅保留内容,因此剩下了大量的空间

主要的函数:

  1. RLP编码: encode(input, buffer, offset) => Buffer 输入"input"可以是{Buffer,String,Integer,Array},RLP编码仅对两种数据结构进行处理:列表及字符串 Nodejs中Array即为列表,其他类型{Buffer,String,Integer}作为字符串处理 该函数的输出结果为RLP编码后的input,类型为Buffer

  2. RLP解码:decode(input, start, end) => Array 输入"input"可以是{Buffer,String,Integer,Array},无论哪种类型,都会被先转换为Buffer类型再进行处理 作用与encode相反,将RLP格式的数据进行解码, 输出为Array类型

  3. 获取长度函数: getLength(input) => Number input为经过RLP编码后的数据 函数根据前几个字节的值获取整个input数据的长度

Keywords

FAQs

Last updated on 15 Sep 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc