Ejemplo n.º 1
0
        public void Setup()
        {
            mnemonic = new MnemonicConverter();

            keys = new Keys
            {
                Curve   = "ed25519",
                Public  = "1nf1T1tUSa43dWglCHzyKIxV61jG/EeeL1Xq1Nk8I3U=.ed25519",
                Private = "GO0Lv5BvcuuJJdHrokHoo0PmCDC/XjO/SZ6H+ddq4UvWd/VPW1RJrjd1aCUIfPIojFXrWMb8R54vVerU2TwjdQ==.ed25519",
                ID      = "@1nf1T1tUSa43dWglCHzyKIxV61jG/EeeL1Xq1Nk8I3U=.ed25519"
            };

            words = "body hair useful camp warm into cause riot two bamboo kick educate dinosaur advice seed type crisp where guilt avocado output rely lunch goddess";
        }
        private void ButtonWordsToKeys_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var words = txtWords.Text;

                var mnemonic = new MnemonicConverter();

                var keys = mnemonic.WordsToKeys(words);

                txtKeys.Text = keys.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                txtKeys.Text = string.Empty;
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine(WriteHelp());
                return;
            }

            string sf           = string.Empty;
            string s            = string.Empty;
            string wf           = string.Empty;
            string w            = string.Empty;
            string mode         = string.Empty;
            string resultSecret = string.Empty;
            string resultWords  = string.Empty;

            foreach (string a in args)
            {
                var parts = a.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length > 1)
                {
                    if (string.Compare("-m", parts[0]) == 0)
                    {
                        mode = parts[1];

                        if (string.Compare(mode, "s2w") != 0 && string.Compare(mode, "w2s") != 0)
                        {
                            Console.WriteLine("invalid -m parameter, please use 's2w' or 'w2s'");
                            return;
                        }
                    }
                    else if (string.Compare("-sf", parts[0]) == 0)
                    {
                        sf = parts[1];
                        if (string.IsNullOrEmpty(sf))
                        {
                            Console.WriteLine("invalid -sf parameter");
                            return;
                        }
                    }
                    else if (string.Compare("-wf", parts[0]) == 0)
                    {
                        wf = parts[1];
                        if (string.IsNullOrEmpty(wf))
                        {
                            Console.WriteLine("invalid -wf parameter");
                            return;
                        }
                    }
                    else if (string.Compare("-s", parts[0]) == 0)
                    {
                        s = parts[1];
                        if (string.IsNullOrEmpty(s))
                        {
                            Console.WriteLine("invalid -s parameter");
                            return;
                        }
                    }
                    else if (string.Compare("-w", parts[0]) == 0)
                    {
                        w = parts[1];
                        if (string.IsNullOrEmpty(w))
                        {
                            Console.WriteLine("invalid -w parameter");
                            return;
                        }
                    }
                }
            }

            if (mode == "s2w")
            {
                if (!string.IsNullOrEmpty(sf))
                {
                    s = System.IO.File.ReadAllText(sf);
                }

                if (string.IsNullOrEmpty(s))
                {
                    Console.WriteLine("no secret specified");
                    return;
                }

                var key = Storage.ReconstructKeys(s);
                MnemonicConverter mnemonicConverter = new MnemonicConverter();
                resultWords = mnemonicConverter.KeysToWords(key);

                if (!string.IsNullOrEmpty(wf))
                {
                    System.IO.File.WriteAllText(wf, resultWords);
                }
                else
                {
                    Console.WriteLine(resultWords);
                }
            }
            else if (mode == "w2s")
            {
                if (!string.IsNullOrEmpty(wf))
                {
                    w = System.IO.File.ReadAllText(wf);
                }

                if (string.IsNullOrEmpty(w))
                {
                    Console.WriteLine("no words specified");
                    return;
                }

                MnemonicConverter mnemonicConverter = new MnemonicConverter();

                var key = mnemonicConverter.WordsToKeys(w);
                resultSecret = Storage.ConstructKeys(key, false);

                if (!string.IsNullOrEmpty(sf))
                {
                    System.IO.File.WriteAllText(sf, resultSecret);
                }
                else
                {
                    Console.WriteLine(resultSecret);
                }
            }
        }