rendered paste body public void BuildTable(byte[] startWord)
{
if (startWord.Length != settings.wordLen)
{
throw new ArgumentException("The Length of the starting word doesnt match the length specified in the settings obj");
}
//vytvorime meno tabulky
//tvar nazvuje tb_dlzkaSlova_pociatocneSlovo.rtb
string tableName = "tb_" + settings.wordLen + "_" + ByteArrayToString(startWord) + ".rtb";
if (File.Exists(settings.tablePath + tableName))
{
throw new FileAlreadyExistsException("A table with the same settings already exists");
}
else
{
file = new FileStream(settings.tablePath + tableName, FileMode.Create, FileAccess.Write, FileShare.None);
}
//najpr generujeme pre prve vychodiskove slovo
this.CreateChain(ref chain, startWord);
rowOfChains.Add(chain[0].word, chain[chain.Count - 1].hash); // pridame prvy riadok
int dumpCount = 0;
//test only
ASCIIEncoding asci = new ASCIIEncoding();
byte[] actualWord = new byte[startWord.Length];
comb = new Combinations(settings.charSet, startWord.Length);
while (comb.MoveNext())
{
for (int i = 0; i < ((object[])comb.Current).Length; i++)
{
char tmp = (char)((object[])comb.Current)[i];
actualWord[i] = (byte)tmp;
}
/*****************BUGGY PART******************************/
chain = new List<Piece>();
this.CreateChain(ref chain, actualWord);
if(!rowOfChains.ContainsKey(chain[0].word))
{
byte[] wordb = chain[0].word;
byte[] hashb = chain[chain.Count - 1].hash;
rowOfChains.Add(wordb,hashb);
}
else
{
continue;
}
Console.WriteLine(asci.GetString(chain[0].word) + " - " + Convert.ToBase64String(chain[chain.Count - 1].hash));
if (Report != null)
{
Report(this, new ReportEventArgument(rowOfChains.Count, chain.Count));
}
dumpCount++;
if (dumpCount == settings.dumpInterval)
{
this.WriteToFile(ref rowOfChains);
dumpCount = 0;
}
}
file.Close();
}