Skip to main content

main/
main.rs

1/*
2 * Copyright (c) 2016 Boucher, Antoni <bouanto@zoho.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of
5 * this software and associated documentation files (the "Software"), to deal in
6 * the Software without restriction, including without limitation the rights to
7 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8 * the Software, and to permit persons to whom the Software is furnished to do so,
9 * subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 */
21
22extern crate password_store;
23
24use password_store::PasswordStore;
25
26fn main() {
27    PasswordStore::insert("pass", "password").unwrap();
28    let password = PasswordStore::get("pass");
29    println!("Password: {:?}", password);
30    let usernames = PasswordStore::get_usernames("pass").unwrap();
31    println!("Usernames: {:?}", usernames);
32    PasswordStore::remove("pass").unwrap();
33
34    PasswordStore::insert("test/pass", "password").unwrap();
35    let password = PasswordStore::get("test/pass");
36    println!("Password: {:?}", password);
37    let usernames = PasswordStore::get_usernames("test/pass").unwrap();
38    println!("Usernames: {:?}", usernames);
39    PasswordStore::remove("test/pass").unwrap();
40
41    PasswordStore::insert("test with spaces/pass with spaces", "password").unwrap();
42    let password = PasswordStore::get("test with spaces/pass with spaces");
43    println!("{:?}", password);
44    let usernames = PasswordStore::get_usernames("test with spaces").unwrap();
45    println!("{:?}", usernames);
46    PasswordStore::remove("test with spaces/pass with spaces").unwrap();
47
48    PasswordStore::generate("pass", true, 25).unwrap();
49    let password = PasswordStore::get("pass");
50    println!("Password: {:?}", password);
51    let usernames = PasswordStore::get_usernames("pass").unwrap();
52    println!("Usernames: {:?}", usernames);
53    PasswordStore::remove("pass").unwrap();
54}