summaryrefslogtreecommitdiff
path: root/IOFileClass/FileManIOFile.hpp
blob: 8a102c7ddaf56bcb208a2eb4c9862df6f6f8c8f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
 * @file FileManIOFile.hpp
 * @brief FileManIOFile class definitions
 * @author manzerbredes
 * @date 9 Mars 2015
 *
 * Contain all definitions of FileManIOFile class.
 *
 */

//--- std -----
#include <iostream>
#include <string>
#include <fstream>

//----- class -----
#include "HASHCrypt.hpp"
#include "AESCrypt.hpp"


/**
 * @class FileManIOFile FileManIOFile.hpp "/CryptClass/FileManIOFile.hpp"
 * @brief Class for quick open and close encrypted file.
 * @author manzerbredes
 *
 * -----File organisation-----
 *
 * 16 first bytes : md5 of decrypted file
 * rest of the file : data encrypted (ASE for now)
 *
 */
class FileManIOFile {

    public:
        FileManIOFile(std::string filename);
        ~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.
        *
        */
        void read(std::string key);

        /**
        * @brief Read encrypted file.
        *
        * @param key : key to encrypt data
        *
        * Save data to "filename" attribute.
        *
        */
        void write(std::string key, std::string data);

        /**
        * @brief True if file fully decrypted.
        *
        * Return "readable" attribute.
        *
        */
        bool isReadable();


        /**
        * @brief Get data attribute.
        *
        * Return "data" attribute.
        *
        * **Warning** if data not fully decrypted (readable!=true),
        * data will be unreadable.
        */
        std::string getData();

    private:

        std::string filename; ///< Filename attribute

        std::string data; ///< Data attribute

        bool readable; ///< Readable attribute





};