--- /dev/null
+// password.cpp
+//
+// Copyright 2010 Micke Nordin <mickewiki@gmail.com>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+#include "password.hpp"
+#include <iostream>
+#include <fstream>
+password::password(std::string enc, std::string dec, std::string k) {
+ encryptedpw = enc;
+ decryptedpw = dec;
+ key = k;
+}
+void password::to_string() {
+ std::cout << "Encrypted: " << encryptedpw << std::endl;
+ std::cout << "Decrypted: " << decryptedpw << std::endl;
+}
+
+bool password::to_file(std::string filename) {
+ bool worked = false;
+ std::ofstream keyfile;
+ if(keyfile.open(filename.c_str())) {
+ keyfile << encryptedpw;
+ keyfile.close();
+ worked = true;
+ }
+ return worked;
+}
+
+bool password::from_file(std::string filename) {
+ bool worked = false;
+ std::ifstream keyfile(filename.c_str());
+ std::string k = "";
+ std::string line = "";
+ if (keyfile.is_open()) {
+ while (! keyfile.eof() ) {
+ getline (keyfile,line);
+ k += line;
+ }
+ keyfile.close();
+ worked = true;
+ }
+ key = k;
+ return worked;
+}
+