0

我正在尝试创建一个基本的 MAC 生成程序。我将很快补充这一点,其中包括教育学。这是我的代码中不起作用的部分:

int inputsh(char inf)
{
    char input; 
    if (input == 'h')
    {
        cout << "winnow.ch is a program based off of the steganographic method coined by Ron Rivest.\nThough winnow.ch does not run off of standalone chaffing & winnowing, it runs through a multistep procedure.\nThe first step it takes after chaffing & winnowing the individual bits is to record and encrypt each bit\nvia a geosynchronous algorithm, and stores them personally on your computer so that nobody else may access the\ndata without having the encrypted UNIX timestamps on their hard drive.\nNext, the numbers are smacked into one huge number, and from there encrypted with 256-bit AES\nand stored inside a passcode-protected read-only file system." << endl;
        cout << "If you would like to read more about winnow.ch and its procedure, enter 'h'." << endl; 
        cout << "If you would like to encrypt text, enter 'e'." << endl;
        cout << "If you would like to decrypt text, enter 'd'." << endl;
        cout << "Choice: "; 
        cin >> input; 
        inputsh(input); 
    }
    else if (input == 'e')
    {
        char* string binary;
        binary = gVariable('c', 0);
        cout << "NOTICE: To begin working with winnow.ch, you must first convert ASCII to binary." << endl;
        cout << "Because it is rather tedious to implement this for a simple C++ program, you must use a convertor." << endl;
        cout << "http://bit.ly/bq2yy3 -- this is a tool programmed by Roubaix Interactive that can convert for you." << endl;
        cout << "I, Beau Perkins, do not own Roubaix Interactive, nor the program that was linked above." << endl; 
        cout << "Once you have converted your full text to binary, please paste it here: " << endl;
        cin >> binary; 
        cout << "Storing each bit inside an array..." << endl;
        int i;
        for(i=0;i<=strlen(binary);i++)
        {
            int* bits; 
            char* string binary;
            binary = gVariable('c', 0);
            bits = gVariable('b', strlen(binary)); 
            bits[i] = binary.substr(i, i); 
            cout << "Generating MAC (message authentication code) for bit..." << endl; 
            ofstream outfile ("MAC.txt"); 
            outfile << bits[i] << ":" << rand() % 1000 << endl;
            outfile.close();
        }
    }
}



我转到终端,g++ main.cpp然后返回以下错误:

main.cpp: In function ‘int gVariable(char, int)’:
main.cpp:20:11: error: invalid conversion from ‘int* (*)[(((unsigned int)(((int)length) + -0x00000000000000001)) + 1)]’ to ‘int’ [-fpermissive]
main.cpp:19:8: warning: address of local variable ‘bits’ returned [enabled by default]
main.cpp:24:16: error: expected initializer before ‘binary’
main.cpp:25:3: error: ‘binary’ was not declared in this scope
main.cpp: In function ‘int inputsh(char)’:
main.cpp:46:16: error: expected initializer before ‘binary’
main.cpp:47:3: error: ‘binary’ was not declared in this scope
main.cpp:59:17: error: expected initializer before ‘binary’

我试图吞下一些我无法咀嚼的东西,但是,这只是经验。发生了什么?

这是gVariable:

int gVariable(char w, int length)
{
    if (w == 'b')
    {
        int* bits[length];
        return &bits;
    }
    if (w == 'c' && length == 0)
    {   
        char* string binary; 
        binary = ""; 
        return &binary;
    }
}
4

0 回答 0