User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cpp:password [2019-03-15 16:09]
ziggi [Password]
cpp:password [2019-05-28 15:26] (current)
Line 6: Line 6:
  * password.cc  * password.cc
  *  *
- * Copyright 2019 Oleg Borodin ​ <​borodin@unix7.org>​+ * Copyright ​2004-2019 Oleg Borodin ​ <​borodin@unix7.org>​
  *  *
  * This program is free software; you can redistribute it and/or modify  * This program is free software; you can redistribute it and/or modify
Line 100: Line 100:
                 if (item.name == name) {                 if (item.name == name) {
                     item.hash = sha256(password);​                     item.hash = sha256(password);​
 +                    return true;
 +                }
 +            }
 +            return false;
 +        }
 +
 +        bool drop(const std::string name) {
 +            size_t i = 0, size = database.size();​
 +            for(i = 0; i < size; i++) {
 +                if (database.at(i).name == name) {
 +                    database.erase(database.begin() + i);
                     return true;                     return true;
                 }                 }
Line 137: Line 148:
     std::cout << "# add and dump:" << std::endl;     std::cout << "# add and dump:" << std::endl;
     p.add(std::​string("​ziggi"​),​ std::​string("​56789"​));​     p.add(std::​string("​ziggi"​),​ std::​string("​56789"​));​
 +    p.dump();
 +
 +    std::cout << "# drop and dump:" << std::endl;
 +    p.drop(std::​string("​ziggi"​));​
     p.dump();     p.dump();
  
Line 158: Line 173:
 qwerty:​5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5 qwerty:​5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5
 ziggi:​f76043a74ec33b6aefbb289050faf7aa8d482095477397e3e63345125d49f527 ziggi:​f76043a74ec33b6aefbb289050faf7aa8d482095477397e3e63345125d49f527
 +
 +# drop and dump:
 +qwerty:​5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5
  
 # check account: ​ # check account: ​