本文介绍了当编译代码防病毒说是病毒并删除它时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试用C ++编写代码.此代码仅使文本文件易于加密并保存到新文件中.当我编译这段代码时,防病毒软件说的是病毒/间谍软件Gen:Variant.Kazy.20825.我不知道为什么是病毒.这是我的代码:

Hi i try to make code in c++. This code only makes text file easy encrypted and save into a new file. And when i compile this code antivirus says, it is virus/spyware Gen:Variant.Kazy.20825. I dont know why it is virus. Here is my code:

#include <iostream>
#include <fstream>
#include <string>


using namespace std;

void controlParameters(int argc){  //check if input parameters are ok
    if(argc == 1){
        cout << "Pokud chcete text zasifrovat, spustte program s parametrem: -enc \"Nazev_souboru.txt\"\n";
        cout << "Pokud ho chcete desifrovat, spustte program s parametrem: -dec \"Nazev_souboru.txt\"\n";
    }else if(argc > 3){
        cout << "Moc parametru. Spustte si program bez parametru.\n";
    }else if(argc < 3){
        cout << "Chybi jeden parametr. Spustte si program bez parametru.\n";
    }else{
        cout << "Vsechno vypada zatim dobre\n";
    }
}

void encryption(string &file);  //encrypt text file
void decryption(string &file);  //decrypt text file
bool controlFile(string &file); //check if file can be opened

int main(int argc, char **argv){
    controlParameters(argc);
    string file;
    file = argv[2];
    if(controlFile(file)){

    }else{
        cout << "Soubor nesel nacist." << endl;
        return -1;
    }
    cout << "Ukonceno.\nZmacknete ENTER pro pokracovani..."<<endl;
    cin.get();
    return 0;
}

bool controlFile(string &file){
    ifstream ifs;
    ifs.open(file);
    if(ifs.is_open()){
        ifs.close();
        return true;
    }else{
        ifs.close();        
        return false;
    }
}

void encryption(string &file){
    ifstream ifs;
    ofstream ofs;
    string line;    
    ifs.open(file);
    ofs.open("encrypt.txt");
    if(ifs.is_open()){
        while(!ifs.eof()){
            getline(ifs,line);
            int a = line.length();
            int i = 0;
            while(i < a){               
                ofs << ((char)(line[i]^100));               
            }
            line.clear();
            ofs << "\n";
        }
    }else{
        cout << "Nelze nacist soubor" << endl;
    }
}

void decryption(string &file){
    ifstream ifs;
    ofstream ofs;
    string line;
    ifs.open(file);
    ofs.open("decrypt.txt");
    if(ifs.is_open()){
        while(!ifs.eof()){
            getline(ifs,line);
            int a =line.length();
            int i = 0;
            while(i < a){               
                ofs << ((char)(line[i]^100));               
            }
            line.clear();
            ofs << "\n";
        }
    }else{
        cout << "Nelze nacist soubor" << endl;
    }
}

推荐答案

从病毒扫​​描程序中排除源代码控制目录是一种很好的做法.即使执行源代码控制操作或编译时没有误报,它们也可能导致性能和锁定问题(我已经见过多次).

It's good practice to exclude your source-control directories from virus scanners; they can cause performance and locking problems even if there are no false positives while performing source-control actions or compiling (I've seen it happen several times).

因此,如果只是为了使您的编程体验更可靠,请在这些目录上禁用病毒扫描程序.

So if only to make your programming experience more reliable, disable the virus scanner on those directories.

您可能仍想扫描可执行文件的最终发行版本,以帮助避免误报:毕竟,即使病毒扫描程序不是您的错,也不会给用户留下很好的印象.

You may still want to scan the final, released version of your executable to help avoid false positives: after all, even if it's not your fault the virus scanner chokes, it's not a good impression to leave behind on a user.

这篇关于当编译代码防病毒说是病毒并删除它时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 08:41