Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6620839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:09:29+00:00 2026-05-25T21:09:29+00:00

First of all the code for aes cryptographic function : void xorcrypto(u_int8_t *key, u_int32_t

  • 0

First of all the code for aes cryptographic function :

void
xorcrypto(u_int8_t *key, u_int32_t keylen,
    u_int8_t *data, u_int32_t datalen)
{

/*u_int8_t ....etc are alias for uint8_t...etc so don't bother about them*/

FILE *fp,*fq,*fr;
int i;
fp=fopen("key","wb");
fwrite((char *)key,keylen,1,fp);
fq=fopen("file.txt","wb");
fwrite((char *)data,datalen,1,fq);

fclose(fq);
fclose(fp);

system("sudo openssl enc -aes-256-cbc -salt -in file.txt
-out file.enc -pass file:key");


/* Here is the code section i need*/

}

What i need in the code section i have specified above is that it should be able to
fill/change the data (pointed by u_int8_t*data) with the contents of file file.enc

Don’t worry about the data length actually the input it is taking is from a n/w ip
packet so it has provision for data upto 1024 bytes and file contents are never going to
exceed this limit.

Here is my attempt for it (also for debugging purpose i need to mention the contents of file.enc as well as data section to stdout)

fr=fopen("file.enc","rb");
memset(data,0,sizeof(data));

i=0;

while( (ch=fgetc(fr))==EOF) {
     data[i]=ch;
     i++;
}

data[i]='\0';
i=0;
puts((char *)data);
printf("\n");
fclose(fr);

Here are some output snapshots which may help …..

udit@udit-Dabba ~/Downloads/sendip-2.5-mec-2/mec $ cat key
thisisaeskey

udit@udit-Dabba ~/Downloads/sendip-2.5-mec-2/mec $ cat file.txt
w�uP����abcd

udit@udit-Dabba ~/Downloads/sendip-2.5-mec-2/mec $ cat file.enc
Salted__����a�dR�P��l�C-<��y�O^Z��/a��3����Q

udit@udit-Dabba ~/Downloads/sendip-2.5-mec-2/mec $ hexdump -C file.enc 
00000000  53 61 6c 74 65 64 5f 5f  b6 f2 b2 d0 61 d9 64 1c  |Salted__....a.d.|
00000010  52 e0 50 96 e8 6c 0e c0  43 2d 3c c4 f6 79 1b d2  |R.P..l..C-<..y..|
00000020  4f 5e 5a b1 d6 2f 61 f8  15 f6 33 e1 88 f0 db 51  |O^Z../a...3....Q|
00000030
udit@udit-Dabba ~/Downloads/sendip-2.5-mec-2/mec $ 

The functon is unable to change the contents of pointed location (u_int8_t *data) and so was unable to write data on stdout puts(data).

Please help me on this …if any further information needed about this i will add it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:09:30+00:00Added an answer on May 25, 2026 at 9:09 pm

    Try changing

    while( (ch=fgetc(fr))==EOF)
    

    into

    while( (ch=fgetc(fr))!=EOF)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have few questions. First of all does code below violates law of Demeter?
First of all, most of the follow code I think is not related to
First of all, I'd like to point out that I'm not asking for code.
This code give me this error: c.apply is not a function All code works
I placed all code below. My page works like that Page's first scene When
First some context: all the code pasted below is within another class declared as
Hi every one first of all im new in zend and i need some
First of all, there are other topics covering this subject but they were posted
First all, I am still learning CakePHP and I am close to ZERO using
I found this code to search for a registry key, it works fine if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.