Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void encrypt(){
- //Opening files where text plain text is read and ciphertext stored
- fp=fopen("input.txt","rb");
- op=fopen("output.txt","wb");
- if (fp==NULL) {fputs ("File error",stderr); exit (1);}
- if (op==NULL) {fputs ("File error",stderr); exit (1);}
- //Initializing the encryption KEY
- AES_set_encrypt_key(ckey, 128, &key);
- //Encrypting Blocks of 16 bytes and writing the output.txt with ciphertext
- while (1) {
- init_ctr(&state, iv); //Counter call
- bytes_read = fread(indata, 1, AES_BLOCK_SIZE, fp);
- AES_ctr128_encrypt(indata, outdata, bytes_read, &key, state.ivec, state.ecount, &state.num);
- bytes_written = fwrite(outdata, 1, bytes_read, op);
- if (bytes_read < AES_BLOCK_SIZE)
- break;
- }
- fclose (fp);
- fclose (op);
- free (buffer);
- }
- int main(int argc, char *argv[]){
- encrypt();
- //decrypt();
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement