using System.Collections.Generic;
using System.Security.Cryptography;
using System.Threading.Tasks;
public static void Main(string[] args)
StringBuilder sb = new StringBuilder();
sb.AppendFormat("Version [{0},{1}] -\nMin: {2}\nMax: {3}", a, b, GenerateAddress((byte)a, (byte)b, 160, false), GenerateAddress((byte)a, (byte)b, 160, true));
public static string GenerateAddress(byte versionByte1, byte versionByte2, int width, bool fFilled)
var hash=new byte[width/8];
for (int i = 0; i < hash.Length; i++)
var bytes=new byte[width/8+2+4];
using(var sha256=new SHA256Managed())
var tmp = sha256.ComputeHash(sha256.ComputeHash(bytes.Take(width/8+2).ToArray()));
for (int i = 0; i < 4; i++)
bytes[bytes.Length - 4 + i] = tmp[i];
return Base58Encode(bytes);
public static string Base58Encode(byte[] array)
const string ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
string retString = string.Empty;
BigInteger encodeSize = ALPHABET.Length;
BigInteger arrayToInt = 0;
for (int i = 0; i < array.Length; ++i)
arrayToInt = arrayToInt * 256 + array[i];
int rem = (int)(arrayToInt % encodeSize);
arrayToInt /= encodeSize;
retString = ALPHABET[rem] + retString;
for (int i = 0; i < array.Length && array[i] == 0; ++i)
retString = ALPHABET[0] + retString;