public void TestGetString() { Console.WriteLine("Test to convert a byte array to a base32 string."); //byte[] test = { 0x3a, 0x27 }; //byte[] test = { 0x27, 0x3a }; byte[] test = { 0x27, 0x3a, 0x33, 0x56, 0x32, 0x05, 0x12, 0x40 }; //byte[] test = { 16, 16 }; //string compare_string = "EAQ"; string base_32_string = Base32.GetString(test); string base_32_string_other = Base32.ToBase32String(test); //Assert.IsTrue(base_32_string == compare_string, "base32 conversion failed.(\"" + base_32_string + "\"!=\"" + compare_string + "\")"); Assert.IsTrue(base_32_string == base_32_string_other, "base32 conversion failed.(\"" + base_32_string + "\"!=\"" + base_32_string_other + "\")"); Console.WriteLine("Get Base32 String Test successful."); }
/* * public void AddTTHL(QueueEntry me) * { * QueueEntry existing = FindExistingEntryForFileList(hub, username); * if (existing == null) * { * QueueEntry entry = new QueueEntry(); * entry.Type = QueueEntry.EntryType.FileList; * string temp_hub_address = hub.Address.Replace(":", "_"); * entry.OutputFilename = filelists_directory + "\\" + temp_hub_address + "-" + Base32.ToBase32String(Encoding.Default.GetBytes(username)) + ".xml.bz2";//TODO .. maybe changes needed here to incorporate other filelist formats * entry.AddSource(new Queue.QueueEntry.Source(username, "", hub)); * lock (queue_lock) * { * items.Add(entry); * } * GrabEntry(entry); * try * { * if (EntryAdded != null) * EntryAdded(entry); * if (EntriesChanged != null) * EntriesChanged(); * } * catch (Exception ex) * { * Console.WriteLine("Exception occured in added event callback: " + ex.Message); * } * * } * }*/ public void AddFileList(Hub hub, string username) { QueueEntry existing = FindExistingEntryForFileList(hub, username); if (existing == null) { QueueEntry entry = new QueueEntry(); entry.Type = QueueEntry.EntryType.FileList; string temp_hub_address = hub.Address.Replace(":", "_"); entry.OutputFilename = filelists_directory + "\\" + temp_hub_address + "-" + Base32.ToBase32String(Encoding.Default.GetBytes(username)) + ".xml.bz2";//TODO .. maybe changes needed here to incorporate other filelist formats entry.AddSource(new Queue.QueueEntry.Source(username, "", hub)); lock (queue_lock) { items.Add(entry); } GrabEntry(entry); try { if (EntryAdded != null) { EntryAdded(entry); } if (EntriesChanged != null) { EntriesChanged(); } } catch (Exception ex) { Console.WriteLine("Exception occured in added event callback: " + ex.Message); } } }