コード例 #1
0
        private static string PromptAndStoreToken()
        {
            Console.Write("The Discord bot token needs to be stored. Enter the token: ");
            string token = Console.ReadLine();

            Console.WriteLine(
                Environment.NewLine +
                "The token will be stored encrypted. You may choose to a use a password to encrypt it. " +
                "If you don't use a password, a default encryption scheme will be used (this is less secure). " +
                Environment.NewLine
                );

            Console.Write("Use a password? (y/n) ");
            string yesno = Console.ReadLine();

            bool usePassword = (yesno.Length > 0 && yesno.Substring(0, 1).ToLower() == "y");

            string password = String.Empty;

            if (usePassword)
            {
                do
                {
                    Console.Write("Enter your password: "******"WARNING: If you forget your password you will have to delete the token file and re-encrypt the token.");
            }
            else
            {
                Console.WriteLine("Using default encryption.");
            }

            BotToken.WriteToken(token, password);
            return(BotToken.GetTokenString());
        }
コード例 #2
0
 private static string StoreToken(string token, string password)
 {
     BotToken.WriteToken(token, password);
     return(BotToken.GetTokenString());
 }