Last active
September 24, 2019 10:30
-
-
Save Hribek25/df03004717cfc6b7b8d46d91beb58f89 to your computer and use it in GitHub Desktop.
IOTA address and checksum
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_csharp.ipynb.html#39B011574CF0 | |
// Requirement: Tangle.Net library (!nuget install Tangle.Net) | |
#r "Tangle.Net.dll" | |
using Tangle.Net.Entity; | |
var myAddr = new Address("CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RW"); //some IOTA address | |
Console.WriteLine("Original input excl. checksum address:"); | |
Console.WriteLine(myAddr.ToString()); | |
Console.WriteLine("Length: " + myAddr.ToString().Length); | |
var AdrIncludingChecksum = new Address(myAddr.ToString() + Checksum.FromAddress(myAddr).ToString()); //generate checksum for the given address and return new address instance that includes checksum | |
// There is a function Withchecksum() but it did not work when tested | |
Console.WriteLine("Input address including checksum:"); | |
Console.WriteLine(AdrIncludingChecksum.ToString() + AdrIncludingChecksum.Checksum.ToString()); //Library still thinks of the address as 2 separate components | |
Console.WriteLine("Length incl checksum: " + (AdrIncludingChecksum.ToString().Length + AdrIncludingChecksum.Checksum.ToString().Length)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment