public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ChargeIntervalFrequency.GetHashCode();
         hashCode = (hashCode * 397) ^ CutoffDayOfMonth.GetHashCode();
         hashCode = (hashCode * 397) ^ CutoffDayOfWeek.GetHashCode();
         hashCode = (hashCode * 397) ^ ExpireAfterSpecificNumberOfCharges.GetHashCode();
         hashCode = (hashCode * 397) ^ (FulfillmentService != null ? FulfillmentService.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Grams.GetHashCode();
         hashCode = (hashCode * 397) ^ (LinePrice != null ? LinePrice.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ OrderDayOfMonth.GetHashCode();
         hashCode = (hashCode * 397) ^ OrderDayOfWeek.GetHashCode();
         hashCode = (hashCode * 397) ^ OrderIntervalFrequency.GetHashCode();
         hashCode = (hashCode * 397) ^ (OrderIntervalUnit != null ? OrderIntervalUnit.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Price != null ? Price.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ ProductId.GetHashCode();
         hashCode = (hashCode * 397) ^ Quantity.GetHashCode();
         hashCode = (hashCode * 397) ^ RequiresShipping.GetHashCode();
         hashCode = (hashCode * 397) ^ (Sku != null ? Sku.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Taxable.GetHashCode();
         hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ VariantId.GetHashCode();
         hashCode = (hashCode * 397) ^ (VariantTitle != null ? VariantTitle.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Vendor != null ? Vendor.GetHashCode() : 0);
         return(hashCode);
     }
 }
Beispiel #2
0
        private void btnCalculateWeight_Click(object sender, EventArgs e)
        {
            {
                try
                {
                    //Get input data from textbox
                    Pounds = double.Parse(txtPounds.Text);
                    //Compute results
                    Kilograms = Pounds / 2.2046886218;
                    //Display Results
                    txtKilograms.Text = Kilograms.ToString("N4");

                    //Get input data from textbox
                    Pounds = double.Parse(txtPounds.Text);
                    //Compute results
                    Grams = Pounds * 453.592;
                    //Display Results
                    txtGrams.Text = Grams.ToString("N4");

                    //Clear Distance Fields when Calculating Weight
                    txtFeet.Clear();
                    txtKilometers.Clear();
                    txtMeters.Clear();
                }

                catch
                {
                    MessageBox.Show("Input a number");
                }
            } //Error Message
        }     //End Method
Beispiel #3
0
        private void GramsSetButton_OnClick(object sender, RoutedEventArgs e)
        {
            var grams = new Grams(NicGrams.QuickParse(), PGGrams.QuickParse(), VGGrams.QuickParse(), WaterGrams.QuickParse(), FlavoringGrams.QuickParse());

            WriteJson(JsonConvert.SerializeObject(grams));

            //Close the popup
            if (Parent is Popup p)
            {
                p.IsOpen = false;
            }
        }
Beispiel #4
0
 /// <summary>
 /// Handle an incoming raw value
 /// </summary>
 /// <param name="dVal"></param>
 public override void ApplyRawValue(double dVal)
 {
     base.ApplyRawValue(dVal);
     if (XferFunc != null)
     {
         Value = XferFunc.Evaluate(dVal);
     }
     else
     {
         Value = dVal;
     }
 }
        public void AnalyzeHillclimbing(bool GPU = false)
        {
            // Initialize analyzer
            this.hillAttacker.Ciphertext         = ciphertext;
            this.hillAttacker.Restarts           = settings.Restarts;
            this.hillAttacker.PlaintextAlphabet  = plaintextalphabet;
            this.hillAttacker.CiphertextAlphabet = ciphertextalphabet;
            this.hillAttacker.grams = grams;
            this.hillAttacker.PluginProgressCallback = this.ProgressChanged;
            this.hillAttacker.UpdateKeyDisplay       = this.UpdateKeyDisplay;

            // Start attack
            hillAttacker.ExecuteOnCPU();
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Quantity.GetHashCode();
         hashCode = (hashCode * 397) ^ ShopifyProductId.GetHashCode();
         hashCode = (hashCode * 397) ^ ShopifyVariantId.GetHashCode();
         hashCode = (hashCode * 397) ^ (Price != null ? Price.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ProductTitle != null ? ProductTitle.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Grams.GetHashCode();
         hashCode = (hashCode * 397) ^ (Vendor != null ? Vendor.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Sku != null ? Sku.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (VariantTitle != null ? VariantTitle.GetHashCode() : 0);
         return(hashCode);
     }
 }
Beispiel #7
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Grams.GetHashCode();
         hashCode = (hashCode * 397) ^ (Images != null ? Images.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Price != null ? Price.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Quantity.GetHashCode();
         hashCode = (hashCode * 397) ^ ShopifyProductId.GetHashCode();
         hashCode = (hashCode * 397) ^ (ShopifyVariantId != null ? ShopifyVariantId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Sku != null ? Sku.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ SubscriptionId.GetHashCode();
         hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (VariantTitle != null ? VariantTitle.GetHashCode() : 0);
         return(hashCode);
     }
 }
Beispiel #8
0
 /// <summary>
 /// Converts the current <see cref="Mass" /> to an array of bytes.
 /// </summary>
 /// <returns>
 /// An array of bytes representing the current <see cref="Mass" />.
 /// </returns>
 public Byte[] ToByteArray() => Grams.ToByteArray();
Beispiel #9
0
 public void Grams_2_pounds()
 {
     FloatCompare(0.0022046228f, Grams.Pounds(1));
 }
Beispiel #10
0
 /// <summary>
 /// Checks for grammemes in current tag
 /// </summary>
 /// <param name="grams">Grammemes to check</param>
 /// <returns>true if current tag contains all this grammemes else false</returns>
 public bool Has(params string[] grams)
 {
     return(grams.All(gram => Grams.Contains(gram)));
 }
Beispiel #11
0
 public string GetString(bool grams)
 {
     return(grams ? Grams.ToString(GramFormat) : Grains.ToString(GrainFormat));
 }
        public void Execute()
        {
            this.genAttacker  = new GeneticAttacker();
            this.dicAttacker  = new DictionaryAttacker();
            this.hillAttacker = new HillclimbingAttacker();

            Boolean inputOK = true;

            // Clear presentation
            ((AssignmentPresentation)Presentation).Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
            {
                try
                {
                    ((AssignmentPresentation)Presentation).Entries.Clear();
                }
                catch (Exception ex)
                {
                    GuiLogMessage("Exception while clearing entries list:" + ex.Message, NotificationLevel.Error);
                }
            }, null);

            // Prepare the cryptanalysis of the ciphertext
            ciphertext = ciphertext.ToLower();

            // Set alphabets
            string lang = LanguageStatistics.LanguageCode(settings.Language);

            grams = new Tetragrams(lang, settings.UseSpaces);

            plaintextalphabet  = grams.Alphabet;
            ciphertextalphabet = String.IsNullOrEmpty(CiphertextAlphabet)
                ? new string(Ciphertext.ToLower().Distinct().OrderBy(c => c).ToArray()).Replace("\r", "").Replace("\n", "")
                : new string(CiphertextAlphabet.ToLower().Distinct().OrderBy(c => c).ToArray()).Replace("\r", "").Replace("\n", "");

            if (ciphertextalphabet[0] == ' ')
            {
                ciphertextalphabet = ciphertextalphabet.Trim() + " ";
            }

            ptAlphabet = new Alphabet(plaintextalphabet);
            ctAlphabet = new Alphabet(ciphertextalphabet);

            if (settings.ChooseAlgorithm == 1)
            {
                ciphertext         = ciphertext.ToLower();
                plaintextalphabet  = plaintextalphabet.ToLower();
                ciphertextalphabet = plaintextalphabet;

                ptAlphabet = new Alphabet(plaintextalphabet);
                ctAlphabet = new Alphabet(ciphertextalphabet);

                // Dictionary
                try
                {
                    langDic = new Dictionary(LanguageStatistics.LanguageCode(settings.Language) + "-small.dic", plaintextalphabet.Length);
                }
                catch (Exception ex)
                {
                    GuiLogMessage(Resources.error_dictionary + ": " + ex.Message, NotificationLevel.Error);
                }
                // Dictionary correct?
                if (this.langDic == null)
                {
                    GuiLogMessage(Resources.no_dictionary, NotificationLevel.Warning);
                }
            }

            // Plaintext Alphabet
            this.plaintextalphabetoutput = plaintextalphabet;
            OnPropertyChanged("PlaintextAlphabetOutput");

            if (ciphertext != null)
            {
                this.cText = new Text(ciphertext.ToLower(), this.ctAlphabet, settings.TreatmentInvalidChars);
            }
            else
            {
                this.cText = null;
            }

            // PTAlphabet correct?
            if (this.ptAlphabet == null)
            {
                GuiLogMessage(Resources.no_plaintext_alphabet, NotificationLevel.Error);
                inputOK = false;
            }

            // CTAlphabet correct?
            if (this.ctAlphabet == null)
            {
                GuiLogMessage(Resources.no_ciphertext_alphabet, NotificationLevel.Error);
                inputOK = false;
            }

            // Ciphertext correct?
            if (this.cText == null)
            {
                GuiLogMessage(Resources.no_ciphertext, NotificationLevel.Error);
                inputOK = false;
            }

            // Check length of ciphertext and plaintext alphabet
            if (this.ctAlphabet.Length > this.ptAlphabet.Length)
            {
                //if ciphertext alphabet is too long, we fallback to the plaintext alphabet
                GuiLogMessage(String.Format(Resources.error_alphabet_length, ciphertextalphabet, ciphertextalphabet.Length, plaintextalphabet, plaintextalphabet.Length), NotificationLevel.Warning);
                ctAlphabet = ptAlphabet;
            }

            // If input incorrect return otherwise execute analysis
            lock (this.stopFlag)
            {
                if (this.stopFlag.Stop)
                {
                    return;
                }
            }

            if (!inputOK)
            {
                inputOK = true;
                return;
            }

            this.UpdateDisplayStart();

            //this.masPresentation.DisableGUI();
            this.masPresentation.UpdateOutputFromUserChoice = this.UpdateOutput;
            this.keyCandidates = new List <KeyCandidate>();

            /* Algorithm:
             * 0 = Hillclimbing CPU
             * 1 = Genetic & Dictionary */
            if (settings.ChooseAlgorithm == 0)
            {
                AnalyzeHillclimbing(false);
                totalKeys = hillAttacker.TotalKeys;
            }
            else if (settings.ChooseAlgorithm == 1)
            {
                if (this.langDic != null)
                {
                    AnalyzeDictionary();
                }
                AnalyzeGenetic();
            }

            this.UpdateDisplayEnd();

            //set final plugin progress to 100%:
            OnPluginProgressChanged(this, new PluginProgressEventArgs(1.0, 1.0));
        }
Beispiel #13
0
 public void Grams_2_kilograms()
 {
     FloatCompare(0.001f, Grams.Kilograms(1));
 }
Beispiel #14
0
 public void Grams_2_tons()
 {
     FloatCompare(0.0000011023113f, Grams.Tons(1));
 }
Beispiel #15
0
 /// <summary>
 /// Compares the current <see cref="Mass" /> to the supplied object and returns an indication of their relative values.
 /// </summary>
 /// <param name="other">
 /// The <see cref="Mass" /> to compare to this instance.
 /// </param>
 /// <returns>
 /// Negative one if this instance is less than the supplied instance; one if this instance is greater than the supplied
 /// instance; zero if they are equal.
 /// </returns>
 public Int32 CompareTo(Mass other) => Grams.CompareTo(other.Grams);
Beispiel #16
0
 public void Grams_2_ounces()
 {
     FloatCompare(0.035273962f, Grams.Ounces(1));
 }
Beispiel #17
0
 /// <summary>
 /// Returns the hash code for this instance.
 /// </summary>
 /// <returns>
 /// A 32-bit signed integer hash code.
 /// </returns>
 public override Int32 GetHashCode() => Grams.GetHashCode();