Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
@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
Param | Type | Description |
---|---|---|
input | string | ascii input |
Converts an ascii encoded string to trytes.
An ascii value of 1 Byte
can be represented in 2 Trytes
:
We get the decimal unicode value of an individual ASCII character.
From the decimal value, we then derive the two tryte values by calculating the tryte equivalent
(e.g.: 100
is expressed as 19 + 3 * 27
), given that tryte alphabet contains 27
trytes values:
a. The first tryte value is the decimal value modulo 27
(which is the length of the alphabet).
b. The second value is the remainder of decimal value - first value
devided by 27
.
The two values returned from Step 2. are then input as indices into the available
trytes alphabet (9ABCDEFGHIJKLMNOPQRSTUVWXYZ
), to get the correct tryte value.
Lets say we want to convert ascii character Z
.
Z
has a decimal unicode value of 90
.
90
can be represented as 9 + 3 * 27
. To make it simpler:
a. First value is 90 % 27 = 9
.
b. Second value is (90 - 9) / 27 = 3
.
Our two values are 9
and 3
. To get the tryte value now we simply insert it as indices
into the tryte alphabet:
a. The first tryte value is '9ABCDEFGHIJKLMNOPQRSTUVWXYZ'[9] = I
b. The second tryte value is '9ABCDEFGHIJKLMNOPQRSTUVWXYZ'[3] = C
Therefore ascii character Z
is represented as IC
in trytes.
Returns: string
- string of trytes
Param | Type | Description |
---|---|---|
trytes | string | trytes |
Converts trytes of even length to an ascii string
Returns: string
- string in ascii
Param | Type | Description |
---|---|---|
input | String | Number | Tryte string or value to be converted. |
Converts trytes or values to trits
Param | Type |
---|---|
trits | Int8Array |
Converts trits to trytes
Param | Type |
---|---|
trits | Int8Array |
Converts trits into an integer value
Param | Type |
---|---|
value | Number |
Converts an integer value to trits
Returns: Int8Array
- trits
FAQs
Convert values & trytes to trits and back
The npm package @iota/converter receives a total of 2,072 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.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.