diff options
| author | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-03-11 16:47:05 +0400 |
|---|---|---|
| committer | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-03-11 16:47:05 +0400 |
| commit | e261782473194273bf29eb033419501d7baf61be (patch) | |
| tree | c203598d20746de24f1a635293f2b2ceea86af48 /IOFileClass/FileManIOFile.cpp | |
| parent | 0b16b8eb9ae5e183d9e5146b3fa268844d69a88b (diff) | |
Change AESCrypt to support mutiple key type (string and byte)
Diffstat (limited to 'IOFileClass/FileManIOFile.cpp')
| -rw-r--r-- | IOFileClass/FileManIOFile.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/IOFileClass/FileManIOFile.cpp b/IOFileClass/FileManIOFile.cpp index d0ae1f2..78758f4 100644 --- a/IOFileClass/FileManIOFile.cpp +++ b/IOFileClass/FileManIOFile.cpp @@ -16,6 +16,7 @@ FileManIOFile::FileManIOFile(std::string filename){ this->filename=filename; this->readable=false; this->data=""; + this->key[0]=NULL; } FileManIOFile::~FileManIOFile(){ } @@ -55,6 +56,7 @@ void FileManIOFile::read(std::string key){ if(hash.compareDigest(fileMD5, currentMD5, sizeof(currentMD5))){ this->readable=true; + hash.getSHA_256(key, this->key, 32); } else{ this->readable=false; @@ -70,8 +72,14 @@ void FileManIOFile::write(std::string key, std::string data){ AESCrypt aes; HASHCrypt hash; + std::string dataEncrypted; - std::string dataEncrypted=aes.encrypt(key, data); + if(this->key!=NULL){ + dataEncrypted=aes.encrypt(key, data); + } + else{ + dataEncrypted=aes.encrypt(this->key, data); + } byte digest[16]; hash.getMD5_128(data, digest, sizeof(digest)); |
