我開始研究加密應用程序,但我似乎非常想到如何讓它顯示進度條,因爲它工作。在控制檯應用程序運行期間的進度條
任務很簡單lSize是被加密文件的總大小。
在C下面的循環++
//********** Open file **********
FILE * inFile = fopen (argv[1], "rb");
fseek(inFile , 0 , SEEK_END);
unsigned long lSize = ftell(inFile);
rewind(inFile);
unsigned char *text = (unsigned char*) malloc (sizeof(unsigned char)*lSize);
fread(text, 1, lSize, inFile);
fclose(inFile);
//*********** Encypt ************
unsigned char aesKey[32] = {
/* Hiding this for now */
};
unsigned char *buf;
aes256_context ctx;
aes256_init(&ctx, aesKey);
for (unsigned long i = 0; i < lSize/16; i++) {
buf = text + (i * 16);
aes256_decrypt_ecb(&ctx, buf);
}
aes256_done(&ctx);
//******************************************************
我不知道我怎麼會顯示進度的for循環,而它的工作原理。
我知道我需要計算到目前爲止做了多少,但我不知道如何去做。
我可能會丟失一些東西很明顯,但爲什麼不乾脆明確和打印任何你想要在控制檯中看到和使用「我」或「X '多少次來展示吧? –