示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string[] sentence = passphrasegen.generateSentenceFromBinary(textBox2.Text);

            string allSentence = string.Join(" ", sentence);

            textBox3.Text = allSentence;
        }
示例#2
0
 public string Post([FromBody] string value)
 {
     try
     {
         PassphraseController passphrasegen = new PassphraseController(AppDomain.CurrentDomain.BaseDirectory + "/dicts/" /*"c:/skola/8.semester/TP/Generator/Dictionaries/"*/);
         string[]             veta          = passphrasegen.generateSentenceFromBinary(value);
         string celaveta = "";
         for (int i = 0; i < veta.Length; i++)
         {
             celaveta += veta[i] + " ";
         }
         return(celaveta);
     }
     catch (Exception e)
     {
         return(e.Message + " " + e.InnerException);
     }
 }
示例#3
0
        static int Main(string[] args)
        {
            /*Worker passphrasegen = new Worker("c:/skola/8.semester/TP/Generator/Dictionaries/");
             * string[] veta = passphrasegen.generateSentenceFromEntrophy(100);
             * string celaveta = "";
             * for (int i = 0; i<veta.Length;i++)
             * {
             *  celaveta += veta[i] + " ";
             * }
             * Console.WriteLine(celaveta);*/

            PassphraseController passphrasegen = new PassphraseController("r:/TP/TP/Generator/Dictionaries/" /*"c:/skola/8.semester/TP/Generator/Dictionaries/"*/);

            string[] veta = passphrasegen.generateSentenceFromBinary("010111011001101010011111010100001011001101");
            //"01011101100110101001111101010000101100110"
            string binary = passphrasegen.generateBinaryFromSentence(string.Join(" ", veta));

            return(0);
        }
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (controller != null)
            {
                Intent i = new Intent();
                switch (item.ItemId)
                {
                case Resource.Id.generateFromEntropy:
                    SetContentView(Resource.Layout.GenerateEntropy);

                    executeButton = FindViewById <Button>(Resource.Id.generateEntropyButton);
                    textOut       = FindViewById <TextView>(Resource.Id.outputTextView);
                    textIn        = FindViewById <EditText>(Resource.Id.entropySizeTextField);

                    executeButton.Click += delegate
                    {
                        int entropy;
                        int.TryParse(textIn.Text, out entropy);

                        textOut.Text = entropy.ToString();
                        textOut.Text = string.Format(String.Join(" ", controller.generateSentenceFromEntrophy(entropy)));
                    };

                    return(true);

                case Resource.Id.translator:
                    SetContentView(Resource.Layout.PasswordTlanslator);

                    executeButton = FindViewById <Button>(Resource.Id.translateButton);
                    textOut       = FindViewById <TextView>(Resource.Id.translatedtextView);
                    textIn        = FindViewById <EditText>(Resource.Id.editTextIn);
                    spinner       = FindViewById <Spinner>(Resource.Id.translateSpinner);

                    spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
                    var adapter = ArrayAdapter.CreateFromResource(
                        this, Resource.Array.passwordTranslateOptions, Android.Resource.Layout.SimpleSpinnerItem);
                    adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);

                    spinner.Adapter = adapter;

                    executeButton.Click += delegate
                    {
                        if (spinnerSelectedItemPosition == 0)
                        {
                            textOut.Text = "Z hesla";
                            textOut.Text = string.Format(String.Join(" ", controller.generateSentenceFromBinary(textIn.Text)));
                        }
                        else
                        {
                            textOut.Text = "Z vety";
                            textOut.Text = controller.generateBinaryFromSentence(textIn.Text);
                        }
                    };

                    return(true);

                case Resource.Id.closeApp:
                    Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                    return(true);

                default:
                    return(false);
                }
            }

            return(false);
        }