⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ciph1.cpp

📁 C++写的加密程序
💻 CPP
字号:
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<fstream>
#include<algorithm>
using namespace std;
string* ciph(string* arg,string& carg);


string* ciph(string* arg,string& carg){
    string::iterator _t;
    _t=arg->begin();
    char ccast;
    while(_t!=arg->end()){
        ccast=*_t;
        switch(ccast){
            case 'a':            {ccast='b';break;}
            case 'b':            {ccast='c';break;}
            case 'c':            {ccast='d';break;}
            case 'd':            {ccast='e';break;}
            case 'e':            {ccast='f';break;}
            case 'f':            {ccast='g';break;}
            case 'g':            {ccast='h';break;}
            case 'h':            {ccast='i';break;}
            case 'i':            {ccast='j';break;}
            case 'j':            {ccast='k';break;}
            case 'k':            {ccast='l';break;}
            case 'l':            {ccast='m';break;}
            case 'm':            {ccast='n';break;}
            case 'n':            {ccast='o';break;}
            case 'o':            {ccast='p';break;}
            case 'p':            {ccast='q';break;}
            case 'q':            {ccast='r';break;}
            case 'r':            {ccast='s';break;}
            case 's':            {ccast='t';break;}
            case 't':            {ccast='u';break;}
            case 'u':            {ccast='v';break;}
            case 'v':            {ccast='w';break;}
            case 'w':            {ccast='x';break;}
            case 'x':            {ccast='y';break;}
            case 'y':            {ccast='z';break;}
            case 'z':            {ccast='a';break;}
            case '0':            {ccast='9';break;}
            case '9':            {ccast='8';break;}
            case '8':            {ccast='7';break;}
            case '7':            {ccast='6';break;}
            case '6':            {ccast='5';break;}
            case '5':            {ccast='4';break;}
            case '4':            {ccast='3';break;}
            case '3':            {ccast='2';break;}
            case '2':            {ccast='1';break;}
            case '1':            {ccast='0';break;}
            case 'A':            {ccast='B';break;}
            case 'B':            {ccast='C';break;}
            case 'C':            {ccast='D';break;}
            case 'D':            {ccast='E';break;}
            case 'E':            {ccast='F';break;}
            case 'F':            {ccast='G';break;}
            case 'G':            {ccast='H';break;}
            case 'H':            {ccast='I';break;}
            case 'I':            {ccast='J';break;}
            case 'J':            {ccast='K';break;}
            case 'K':            {ccast='L';break;}
            case 'L':            {ccast='M';break;}
            case 'M':            {ccast='N';break;}
            case 'N':            {ccast='O';break;}
            case 'O':            {ccast='P';break;}
            case 'P':            {ccast='Q';break;}
            case 'Q':            {ccast='R';break;}
            case 'R':            {ccast='S';break;}
            case 'S':            {ccast='T';break;}
            case 'T':            {ccast='U';break;}
            case 'U':            {ccast='V';break;}
            case 'V':            {ccast='W';break;}
            case 'W':            {ccast='X';break;}
            case 'X':            {ccast='Y';break;}
            case 'Y':            {ccast='Z';break;}
            case 'Z':            {ccast='A';break;}

            default: break;
        }
        *_t=ccast;
        ++_t;
    }
    carg=*arg;
    return arg;
}


int main(){
    char ch;
    string word;
        word="work";
        cout<<word;
    vector<string> article;
    vector<string> ciphtex;
        //article[0]="ffar";
    short wordcount=0,pause,k,n;
    FILE *_f,*_ph;
    ifstream in("original.txt");

    printf(">   now printing the original article...\n");

    //core read

    while(getline(in,word,'\n')){
        article.push_back(word);
    }


    vector<string>::iterator _it;
    string str,*_str,ciphstr;
    _it=article.begin();
    while(_it!=article.end()){
        cout<<*_it;
        str=*_it;
        _str=&str;
        ciph(_str,ciphstr);
        *_it=ciphstr;
        ++_it;++wordcount;
    }

    printf("\n>   This article contains %d lines\n",wordcount);
    printf("\n>   now encrypting...\n\n");

    ofstream out("encrypted.txt");


    _it=article.begin();
    while(_it!=article.end()){
        cout<<*_it;
        out<<*_it;
        ++_it;
    }




    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -