Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@iota/converter
Advanced tools
Methods for converting ascii, values & trytes to trits and back.
Install using npm:
npm install @iota/converter
or using yarn:
yarn add @iota/converter
Summary: Converts ASCII characters to trytes.
Throws:
errors.INVALID_ASCII_CHARS
: Make sure that the input
argument contains only valid ASCII characters.Param | Type | Description |
---|---|---|
input | string | ASCII input |
This method converts ASCII characters to trytes.
To convert trytes to ASCII characters, use the trytesToAscii()
method.
Returns: string
- Trytes
Example
let trytes = Converter.asciiToTrytes('Hello, where is my coffee?');
Summary: Converts trytes to ASCII characters.
Throws:
errors.INVALID_TRYTES
: Make sure that the trytes
argument contains only valid trytes (A-Z or 9).errors.INVALID_ODD_LENGTH
: Make sure that the trytes
argument contains an even number of trytes.Param | Type | Description |
---|---|---|
trytes | string | An even number of trytes |
This method converts trytes to ASCII characters.
Because each ASCII character is represented as 2 trytes, the given trytes must be of an even length.
To convert ASCII characters to trytes, use the asciiToTrytes()
method.
Returns: string
- ASCII characters
Example
let message = Converter.trytesToAscii('IOTA');
Summary: Converts trytes to trits.
Throws:
errors.INVALID_TRYTES
: Make sure that the input
argument contains only valid trytes (A-Z or 9).Param | Type | Description |
---|---|---|
input | String | number | Trytes |
This method converts trytes to trits.
To convert ASCII characters to trytes, use the asciiToTrytes()
method.
Returns: Int8Array
- trits
Example
let trits = Converter.trytesToTrits('IOTA');
Summary: Converts trits to trytes.
Throws:
errors.INVALID_TRITS
: Make sure that the input
argument contains an array of trits.Param | Type | Description |
---|---|---|
input | String | number | Trits |
This method converts trits to trytes.
To convert trytes to ASCII characters, use the trytesToAscii()
method.
Returns: Int8Array
- trytes
Example
let trytes = Converter.tritsToTrytes(trits);
Summary: Converts trits to a number.
Param | Type | Description |
---|---|---|
input | String | number | Trits |
This method converts trits to a number.
To convert trytes to trits, use the trytesToTrits()
method.
To convert trits to trytes, use the tritsToTrytes()
method.
Returns: Int8Array
- number
Example
let number = Converter.tritsToValue(trits);
Summary: Converts trits to a number.
Param | Type | Description |
---|---|---|
input | String | number | Number |
This method converts a number to trits.
To convert trits to trytes, use the tritsToTrytes()
method.
Returns: Int8Array
- trits
Example
let trits = Converter.valueToTrits(9);
FAQs
Convert values & trytes to trits and back
The npm package @iota/converter receives a total of 9,048 weekly downloads. As such, @iota/converter popularity was classified as popular.
We found that @iota/converter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.