From 9b99763c2ed924e340c7dbf73842207ba56ed125 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Fri, 13 Mar 2015 15:39:56 +0400 Subject: Check all IOFileClass. --- IOFileClass/FileManIOFile.hpp | 69 ++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 27 deletions(-) (limited to 'IOFileClass/FileManIOFile.hpp') diff --git a/IOFileClass/FileManIOFile.hpp b/IOFileClass/FileManIOFile.hpp index 7013b27..221cf13 100644 --- a/IOFileClass/FileManIOFile.hpp +++ b/IOFileClass/FileManIOFile.hpp @@ -12,40 +12,51 @@ #ifndef __FileManIOFile__ #define __FileManIOFile__ -//--- std ----- + +//----- std ----- #include #include #include + //----- class ----- #include "HASHCrypt.hpp" #include "AESCrypt.hpp" + + /** * @class FileManIOFile FileManIOFile.hpp "/CryptClass/FileManIOFile.hpp" - * @brief Class for quick open and close encrypted file. + * @brief Class for quick open and close encrypted files. * @author manzerbredes * * -----File organisation----- * - * 16 first bytes : md5 of decrypted file - * rest of the file : data encrypted (ASE for now) + * 16 first bytes : md5 of decrypted data + * Rest of the file : data encrypted (ASE for now) * + * \bug Need check if file exist and can be opened */ class FileManIOFile { public: + + //Constructor FileManIOFile(std::string filename); + + //Destructor ~FileManIOFile(); + /** * @brief Read encrypted file. * * @param key : key to encrypt data * * Read data from "filename" attribute. - * If file fully decrypted, readable var switch to true. + * If file fully decrypted, readable var switch to true, + * and key saved in key attribute (before been crypted with SHA-256 algorithm). * */ void read(std::string key); @@ -57,32 +68,20 @@ class FileManIOFile { * @param key : key to encrypt data * @param data : data to write * - * Write the file with or without key + * Write the file with or without key. * To write data without key, you need to read it before (to save the key - * in attribute key; + * in attribute key). * */ void write(std::string key, std::string data); void write(std::string data); - /** - * @brief Write data in encrypted file. - * - * @param data : data to write (for MD5) - * @param dataEncrypted : data to write - * - * Write encryptedData to filename - * - */ - void writeRoutine(std::string data, std::string dataEncrypted); - - - - /** * @brief True if file fully decrypted. * + * @return readable attribute + * * Return "readable" attribute. * */ @@ -92,26 +91,42 @@ class FileManIOFile { /** * @brief Get data attribute. * - * Return "data" attribute. + * @return data attribute. * * **Warning** if data not fully decrypted (readable!=true), - * data will be unreadable. + * data will be unreadable (unparsable). + * */ std::string getData(); + private: - std::string filename; ///< Filename attribute + /** + * @brief Write data in encrypted file. + * + * @param data : data to write (for MD5) + * @param dataEncrypted : data to write + * + * Write encryptedData to filename + * + */ + void writeRoutine(std::string data, std::string dataEncrypted); - std::string data; ///< Data attribute - bool readable; ///< Readable attribute + //Attributes: - byte key[32]; ///< Key in SHA-256 + AESCrypt aes; ///< AES instance + HASHCrypt hash; ///< HASH instance + std::string filename; ///< Filename attribute + std::string data; ///< Data attribute + bool readable; ///< Readable attribute + + byte key[32]; ///< Key in SHA-256 }; -- cgit v1.2.3