Changeset 1689


Ignore:
Timestamp:
Jun 22, 2010, 5:14:25 PM (11 years ago)
Author:
Sven Rech
Message:

changed quadratic sieve color generation

Location:
trunk/CrypPlugins/QuadraticSieve
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/QuadraticSieve/PeerToPeer.cs

    r1678 r1689  
    8888        {
    8989            string username = WindowsIdentity.GetCurrent().Name;
    90             string mac = GetMac();
     90            string mac = GetMacIdentifier();
    9191
    9292            MD5 md5 = new MD5CryptoServiceProvider();
    93             byte[] idBytes = md5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(username + mac));           
    94            
    95             //Is it really a good idea to calculate the ID like this?
    96             for (int c = 0; c < idBytes.Length; c++)           
    97                 ourID = ourID + (idBytes[c] << c);
    98 
     93            byte[] idBytes = md5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(username + mac));
     94
     95            ourID = BitConverter.ToInt32(idBytes, 3);
    9996            quadraticSieveQuickWatchPresentation.ProgressYields.setOurID(ourID);
    10097
     
    434431       
    435432        /// <summary>
    436         /// Returns our MAC address
     433        /// Returns an identifier that depends on the MAC addresses of this system
    437434        /// </summary>       
    438         private string GetMac()
    439         {
    440             string Mac = string.Empty;
     435        private string GetMacIdentifier()
     436        {
     437            string MacID = "";
    441438            ManagementClass MC = new ManagementClass("Win32_NetworkAdapter");
    442439            ManagementObjectCollection MOCol = MC.GetInstances();
    443440            foreach (ManagementObject MO in MOCol)
    444441                if (MO != null)
    445                 {
    446442                    if (MO["MacAddress"] != null)
    447                     {
    448                         Mac = MO["MACAddress"].ToString();
    449                         if (Mac != string.Empty)
    450                             break;
    451                     }
    452                 }
    453             return Mac;
     443                        MacID += MO["MACAddress"].ToString();
     444            return MacID;
    454445        }
    455446
  • trunk/CrypPlugins/QuadraticSieve/ProgressYields.xaml.cs

    r1678 r1689  
    114114        private bool SimilarColors(Color col1, Color col2)
    115115        {
    116             const int toleratedDifference = 20;
     116            const int toleratedDifference = 15;
    117117            int diffR = Math.Abs(col1.R - col2.R);
    118118            int diffG = Math.Abs(col1.G - col2.G);
Note: See TracChangeset for help on using the changeset viewer.