add file decrypt and encryt driver code

Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
This commit is contained in:
2021-05-06 23:40:17 +05:30
parent 6b264873f2
commit eb966005ca
2 changed files with 9 additions and 6 deletions

View File

@@ -25,5 +25,3 @@ file(GLOB KRYPTO_INC ${PROJECT_SOURCE_DIR}/include/*.h)
add_executable(${PROJECT_NAME} ${KRYPTO_SRC} ${KRYPTO_INC}) add_executable(${PROJECT_NAME} ${KRYPTO_SRC} ${KRYPTO_INC})
target_include_directories(${PROJECT_NAME} PRIVATE blowfish/include PUBLIC include) target_include_directories(${PROJECT_NAME} PRIVATE blowfish/include PUBLIC include)
target_link_libraries(${PROJECT_NAME} blowfish) target_link_libraries(${PROJECT_NAME} blowfish)

View File

@@ -21,9 +21,14 @@ int main(int argc, char const *argv[]) {
test.pad_input(buffer, stat.filesize); test.pad_input(buffer, stat.filesize);
krypto::Encryptor encryptor; krypto::Encryptor encryptor;
// encryptor.blowfish_encrypt(buffer, password, stat.filesize); int pos;
encryptor.blowfish_decrypt(buffer,password,stat.filesize); if ((pos = filename.find("krypto")) != std::string::npos) {
test.write_file(filename.substr(8) , buffer, stat.filesize); encryptor.blowfish_decrypt(buffer, password, stat.filesize);
test.write_file(filename.substr(0, pos-1), buffer, stat.filesize);
} else {
encryptor.blowfish_encrypt(buffer, password, stat.filesize);
test.write_file(filename + ".krypto", buffer, stat.filesize);
}
return 0; return 0;
} }