ToBase58() 공개 메소드

Returns the Base58 encoding of the MultiHash.
public ToBase58 ( ) : string
리턴 string
예제 #1
0
        public void Base58_Encode_Decode()
        {
            var mh = new MultiHash("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB");

            Assert.AreEqual("sha2-256", mh.Algorithm.Name);
            Assert.AreEqual(32, mh.Digest.Length);
            Assert.AreEqual("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB", mh.ToBase58());
        }
예제 #2
0
        /// <summary>
        ///   Converts the CID to its equivalent string representation.
        /// </summary>
        /// <returns>
        ///   The string representation of the <see cref="Cid"/>.
        /// </returns>
        /// <remarks>
        ///   For <see cref="Version"/> 0, this is equalivalent to the
        ///   <see cref="MultiHash.ToBase58()">base58btc encoding</see>
        ///   of the <see cref="Hash"/>.
        /// </remarks>
        /// <seealso cref="Decode"/>
        public string Encode()
        {
            if (Version == 0)
            {
                return(Hash.ToBase58());
            }

            using (var ms = new MemoryStream())
            {
                ms.WriteVarint(Version);
                ms.WriteMultiCodec(ContentType);
                Hash.Write(ms);
                return(MultiBase.Encode(ms.ToArray(), Encoding));
            }
        }
예제 #3
0
 /// <summary>
 ///   Converts the CID to its equivalent string representation.
 /// </summary>
 /// <returns>
 ///   The string representation of the <see cref="Cid"/>.
 /// </returns>
 /// <remarks>
 ///   For <see cref="Version"/> 0, this is equalivalent to the
 ///   <see cref="MultiHash.ToBase58()">base58btc encoding</see>
 ///   of the <see cref="Hash"/>.
 /// </remarks>
 /// <seealso cref="Decode"/>
 public string Encode()
 {
     if (encodedValue != null)
     {
         return(encodedValue);
     }
     if (Version == 0)
     {
         encodedValue = Hash.ToBase58();
     }
     else
     {
         using (var ms = new MemoryStream())
         {
             ms.WriteVarint(Version);
             ms.WriteMultiCodec(ContentType);
             Hash.Write(ms);
             encodedValue = MultiBase.Encode(ms.ToArray(), Encoding);
         }
     }
     return(encodedValue);
 }
예제 #4
0
 public override void ReadValue(CodedInputStream stream)
 {
     stream.ReadLength();
     MultiHash = new MultiHash(stream);
     Value     = MultiHash.ToBase58();
 }