Ejemplo n.º 1
0
        public void DecryptAll(DecryptFormat format)
        {
            // This is going to stdout out, don't bother securing the memory here
            var decrypted = new Dictionary <string, dynamic>();

            foreach (var k in _sman.Keys)
            {
                var v = _sman.Get(k);
                decrypted[k] = v;
            }

            switch (format)
            {
            case DecryptFormat.PlainText:
                foreach (var k in decrypted.Keys)
                {
                    Console.WriteLine($"{k}: { decrypted[k].ToString() }");
                }
                break;

            default:
                var serializerOptions = JsonConvert.SerializeObject(decrypted, Formatting.Indented);
                Console.WriteLine(serializerOptions);
                break;
            }
        }
Ejemplo n.º 2
0
        private static bool TryGetCredentials(out string userName, out string userToken)
        {
            userName = userToken = null;
            if (!GetSecret(SecretsManager.GitHubUsername, "What is your GitHub user name?", out userName))
            {
                Console.WriteLine("This is needed...exiting");
                userName = userToken = null;
                return(false);
            }
            else
            {
                SecretsManager.Set(SecretsManager.GitHubUsername, userName);
                Console.WriteLine($"Your GitHub username is {SecretsManager.Get(SecretsManager.GitHubUsername)}.");
            }

            if (!GetSecret(SecretsManager.GitHubUserToken, "What is your GitHub user token?", out userToken))
            {
                Console.WriteLine("This is needed...exiting");
                userName = userToken = null;
                return(false);
            }
            else
            {
                SecretsManager.Set(SecretsManager.GitHubUserToken, userToken);
                GitHubQlService.SetAuthToken(userToken);
                Console.WriteLine("Your GitHub auth token is set.");
            }
            Console.WriteLine();

            SecretsManager.Save();
            Console.WriteLine("You can clear both of these by running this command with a `clear` argument.");
            Console.WriteLine();

            return(true);
        }