Changeset 866
 Timestamp:
 Nov 17, 2009, 10:07:19 PM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/CrypPlugins/KeySearcher/KeySearcher.cs
r865 r866 11 11 using System.Threading; 12 12 using System.Windows.Threading; 13 using Cryptool.PluginBase.Miscellaneous; 13 14 14 15 namespace KeySearcher … … 223 224 } 224 225 225 public longinitKeyIteration(string key)226 { 227 longcounter = 1;226 public BigInteger initKeyIteration(string key) 227 { 228 BigInteger counter = 1; 228 229 this.key = key; 229 230 int pcount = 0; … … 246 247 } 247 248 248 public longsize()249 public BigInteger size() 249 250 { 250 251 if (wildcardList == null) 251 252 return 0; 252 longcounter = 1;253 BigInteger counter = 1; 253 254 foreach (Wildcard wc in wildcardList) 254 255 counter *= wc.size(); … … 446 447 KeyPattern[] patterns = (KeyPattern[])parameters[0]; 447 448 int threadid = (int)parameters[1]; 448 Int64[] doneKeysArray = (Int64[])parameters[2];449 Int64[] keycounterArray = (Int64[])parameters[3];450 Int64[] keysLeft = (Int64[])parameters[4];449 BigInteger[] doneKeysArray = (BigInteger[])parameters[2]; 450 BigInteger[] keycounterArray = (BigInteger[])parameters[3]; 451 BigInteger[] keysLeft = (BigInteger[])parameters[4]; 451 452 IControlEncryption sender = (IControlEncryption)parameters[5]; 452 453 int bytesToUse = (int)parameters[6]; … … 461 462 while (pattern != null) 462 463 { 463 longsize = pattern.size();464 BigInteger size = pattern.size(); 464 465 keysLeft[threadid] = size; 465 466 int nextWildcard; … … 683 684 684 685 KeyPattern[] patterns = new KeyPattern[settings.CoresUsed+1]; 685 longsize = Pattern.initKeyIteration(settings.Key);686 BigInteger size = Pattern.initKeyIteration(settings.Key); 686 687 687 688 if (settings.CoresUsed > 0) … … 695 696 { 696 697 int maxPattern = 1; 697 longmax = 0;698 BigInteger max = 0; 698 699 for (int i = 0; i <= p; i++) 699 700 if (patterns[i].size() > max) … … 713 714 valuequeue = Queue.Synchronized(new Queue()); 714 715 715 Int64[] doneKeysA = new Int64[patterns.Length];716 Int64[] keycounters = new Int64[patterns.Length];717 Int64[] keysleft = new Int64[patterns.Length];716 BigInteger[] doneKeysA = new BigInteger[patterns.Length]; 717 BigInteger[] keycounters = new BigInteger[patterns.Length]; 718 BigInteger[] keysleft = new BigInteger[patterns.Length]; 718 719 Stack threadStack = Stack.Synchronized(new Stack()); 719 720 for (int i = 0; i < patterns.Length; i++) 720 721 { 721 722 WaitCallback worker = new WaitCallback(KeySearcherJob); 722 doneKeysA[i] = new Int64();723 keycounters[i] = new Int64();723 doneKeysA[i] = new BigInteger(); 724 keycounters[i] = new BigInteger(); 724 725 ThreadPool.QueueUserWorkItem(worker, new object[] { patterns, i, doneKeysA, keycounters, keysleft, sender.clone(), bytesToUse, threadStack }); 725 726 } … … 759 760 while (node != null) 760 761 { 761 762 762 if (vk.value < node.Value.value) 763 763 { … … 773 773 } 774 774 775 longkeycounter = 0;776 longdoneKeys = 0;777 foreach ( Int64dk in doneKeysA)775 BigInteger keycounter = 0; 776 BigInteger doneKeys = 0; 777 foreach (BigInteger dk in doneKeysA) 778 778 doneKeys += dk; 779 foreach ( Int64kc in keycounters)779 foreach (BigInteger kc in keycounters) 780 780 keycounter += kc; 781 781 … … 787 787 { 788 788 maxThreadMutex.WaitOne(); 789 longmax = 0;789 BigInteger max = 0; 790 790 int id = 1; 791 791 for (int i = 0; i < patterns.Length; i++) … … 798 798 maxThreadMutex.ReleaseMutex(); 799 799 } 800 801 ProgressChanged( keycounter, size);800 801 ProgressChanged(Math.Pow(10, keycounter.log(10)  size.log(10)), 1.0); 802 802 803 803 if (QuickWatchPresentation.IsVisible && doneKeys != 0 && !stop) 804 804 { 805 double time = ( (size  keycounter) / doneKeys);805 double time = (Math.Pow(10, (size  keycounter).log(10)  doneKeys.log(10))); 806 806 TimeSpan timeleft = new TimeSpan(1); 807 807
Note: See TracChangeset
for help on using the changeset viewer.