New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

solidity-bytesutil

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solidity-bytesutil

Solidity library to manipulate bytes

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

solidity-bytesutil

A Solidity library to manipuate bytes.

Quick start

Import BytesUtil.sol and add this line to the beginning of your contract

using BytesUtil for bytes;

Functions

function slice(bytes bs, uint start, uint length)

Copies of a portion of a byte array into a new byte array.

Example

bytes memory bs = new bytes[](3);
bs[0] = 0x01
bs[1] = 0x02
bs[2] = 0x03
bytes sliced = bs.slice(1, 2)
// sliced is array [0x02, 0x03]

function sliceUint(bytes bs, uint start)

Gets an uint from a byte array

Example

bytes memory bs = abi.encode(42, 1337)
uint num = bs.sliceUint(32)
// num is 1337

function sliceUintArray(bytes bs, uint start, uint count)

Gets an uint array from a byte array

Example

bytes memory bs = abi.encode(42, 1337, 9001)
uint[] nums = bs.sliceUintArray(32, 2)
// nums is [1337, 9001]

function toUintArray(bytes bs)

Gets a uint array from the data in a byte array

Example

bytes memory bs = abi.encode(42, 1337, 9001)
uint[] nums = bs.toUintArray()
// nums is [42, 1337, 9001]

Keywords

ethereum

FAQs

Package last updated on 15 Jul 2018

Did you know?

Socket

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