示例#1
0
        static void CreateNewList()
        {
            if (File.Exists(GetAbsolutePath("list")))
            {
                if (!PromptConfirm("You already have a keylist. Overwrite?"))
                {
                    return;
                }
            }

            string password = DiscreetPrompt("Enter password");

            byte[] salt = CryptoBox.GetRandomBytes(16);

            File.WriteAllBytes(GetAbsolutePath("salt"), salt);

            Console.Write("Generating key...");
            byte[] key = CryptoBox.GenerateKeyFromPassword(password, salt, CryptoBox.DefaultKeySize);
            Key = key;
            Console.WriteLine("done.");

            PasswordList list = new PasswordList();

            CryptoBox.SafeSerialize(list, key, GetAbsolutePath("list"));

            List = list;

            Console.WriteLine("Created new encrypted keylist.");

            AfterUnlock();
        }
示例#2
0
 static void Save()
 {
     CryptoBox.SafeSerialize(List, Key, GetAbsolutePath("list"));
 }