Last active
September 24, 2019 10:30
-
-
Save Hribek25/e56f314a5bfa5d669bc092d185ff01a0 to your computer and use it in GitHub Desktop.
Conversion: trytes and trits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The snippet is a part of the IOTA Developer Essentials project. You can reach it at https://hribek25.github.io/IOTA101/ | |
// Complete description and story behind the snippet is available at: https://hribek25.github.io/IOTA101/Allchapters_javascript.ipynb.html#3BB8C879CCAE | |
// Requirement: A converter module of IOTA Javascript Library (!npm install @iota/converter) | |
var Converter = require('@iota/converter') //loading helping converter module of iota.js library. More info: https://github.com/iotaledger/iota.js/tree/next/packages/converter#module_converter.trits | |
var Trytes = "YZJEATEQ9JKLZ" //some data encoded in Trytes | |
console.log(Trytes) | |
console.log("Number of Trytes: %s" , Trytes.length) | |
var Trits = Converter.trits(Trytes) //converting Trytes to Trits | |
console.log(Trits.join(",")) | |
console.log("Number of trits: %s", Trits.length) //Number of trits is three times the number of trytes obviously |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment