BCNet.Utils.DecodeBase58String C# (CSharp) Method

DecodeBase58String() public static method

public static DecodeBase58String ( string encoded ) : byte[]
encoded string
return byte[]
        public static byte[] DecodeBase58String(string encoded)
        {
            const string staticBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";

            BigInteger bi = 0;
            foreach (char c in encoded)
            {
                int idx = staticBase58.IndexOf(c);
                if (idx < 0)
                {
                    if (c != '\0')
                        return null;
                    break;
                }
                bi *= 58;
                bi += idx;
            }
            byte[] data = bi.ToByteArray();
            byte[] swapped = new byte[data.Length];
            for (int i = 0; i < data.Length; i++)
                swapped[i] = data[data.Length - (i + 1)];
            return swapped;
        }