Here is the state of the address and decoding Address Ethereum with the Base58 C#:
Base58 Coding and Decoding C C#: Guide
Address Ethereum is submitted in the type of tip base58 for prostate and reading. In this hand, we dissatisfied with how to make-58 and decodes the address c#.
BASE58 Fleae Ponimania
Before you subtract into the code, let’s flood the basis of coding58:
- 4 Thats (
0x ...
) indicates the character.
- Remaining symbols subordinated by the following image:
+ 0
GetB
+ 1
+ 2 'gets d
+3Geting
+5Get
F
+6
+7
+8
+9Get
J
Left -handed persongains are more designed in two categories:
* SUBMAND Personal : Ony is a bodied as a book (A-Z, A-Z)
* Bengular Simwear : Ony is a sophodated as a sca (0-9)
Base58 Code C#
Here are the basic basis58 coding and decoding of the introduction:
csharp
Using the system;
Using. Text;
Social Statical Class Ethereumaddressencoder
{
PUBLIC Static Series Encodeaddress (Strong Adreso)
{
// Normalisatuating zeros
Raad Normalizedaddress = Normalizeleadingzeros (address);
// Availab
Byte [] bytes = bitconverter.getbytes (normalizeddress);
Raad oncodedaddress = bitconverter.tostring (BYTE) .Replace ("-" "");
Return Codeddress;
}
Public Statical Series Decodeedress (Dade Dade)
{
// Make strikes and seal prefix and body
Series [] parts = oncodaddress.plit ('-');
IF (partS.LendGh! = 2) Brating the New Argue Exception ("Invalid Address Baza58");
Byte [] bytes = bitconverter.getbytes (parts [0]);
Int Bodylengtth = Bitconverter.Toint32 (parts [1], 0);
series decoded housing = bitconverter.tostring (byte) .Replace ("-" "");
string Decodaddress = $ "{Parts [0] .substring (0, Bodylendth)}: {Decoded Corps}";
Returns Decodaddrrress;
}
Private Static Series Normizualiding (Strong Adres)
{
Stringbuilder SB = New Stringbuilder ();
Foreach (ADR C Red)
{
IF (C == '')
{
Sb.append (');
}
others
{
Sb.append (C);
}
}
return sb.tostring ();
}
}
Primer use
Let’s coded the Obroza Address Ethereum:
`csharp
Red oncodedaddress = Ethereumaddressencoder.encodeaddress ("0x1234567890abcdef");
Console.Writeline ($ "Code: {incodedaddress}");
And then to disperse this:
`csharp
Series decodedaddress = Ethereumaddressecoder.decodeaddress (Coding Dadress);
Console.writeline ($ "Decode Address: {Decodedaddress}");
What is the “Normalization of the Presentation”?
In the “Normizeleadingzeros” method, we take the series of the entrances and the part of each symbol. If the symbol – this is a stretching (“” ‘), we simply add it to it.
This process efficiently succeeds in all in the water pads, guaranteeing that our coded addresses to the same, as the body will not have any adoration of symbols. This is a particularly clear work with the textual data, it is possible to instruct the readings and the code.