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

  • Home
  • SEARCH
  • 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 8938423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:37:17+00:00 2026-06-15T10:37:17+00:00

The following code produces a text file with an encoded message derived from a

  • 0

The following code produces a text file with an encoded message derived from a different, readable textfile.

   #include <stdio.h>
   #include <time.h>
   #include <stdlib.h>

   main()
   {
     FILE *f, *f_enc;
     char c, c_enc;
     int ind, a[26], r_val;

     srandom(time(NULL));
     for (ind=0; ind<26; ind++) a[ind]=-1; 
     for (ind=0; ind<26; ind++){
       do
         r_val=random()%26;
       while (a[r_val]!=-1);
       a[r_val]=ind;
     }

     f=fopen("plain.txt","r");
     f_enc=fopen("cipher.txt","w");
     while (!feof(f)) {
       c=fgetc(f);
       if ((c>='A' && c<='Z')||(c>='a' && c<='z')) {
         if (c>='A' && c<='Z') c = c + 'a' - 'A';
         c=a[c-'a']+'a';
       }
       fputc(c,f_enc);
     }
     fclose(f);
     fclose(f_enc);
   }

What I am unclear of is the overal algorithm the code is implementing to encode a message.

  • Is it subtracting an ASCII value (‘a – ‘A) from the character to produce an encoded character?

An example output is given below:

xohq xpu ouuf yubliu spieqxkhq, hzj hcc xpilnap xpu plnqu
tln slncj puhi ku yuhxeza xpu slkmnxui oexp xpu klnqu.
xpu jeqf ohq pnza nm ez xpu jeqf jieru oexp shiu,
hzj, zuujcuqq xl qht, e zuhict mnccuj lnx kt phei.

e ahru nm bli xphx zeapx, alx iuhjt bli yuj,
hzj olzjuiuj, "qplncj e gnqx ynt shijq ezqxuhj?"
khkh hzj jhjjt phj gnqx pex xpu pht,
ql e xlcj xpuk allj zeapx, hzj ouzx lz kt oht.

I’m going to try to reverse engineer this to see if I can get ahold of what’s going on.
Any speculation is welcomed!

  • 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-06-15T10:37:18+00:00Added an answer on June 15, 2026 at 10:37 am

    This is a simple substitution, such as is used in a cryptogram puzzle. It can be solved with letter frequency analysis.

    There exist automated solvers. The original text for the example is:

    twas the week before christmas, and all through the house you could
    hear me beating the computer with the mouse. the disk was hung up in
    the disk drive with care, and, needless to say, i nearly pulled out my
    hair. i gave up for that night, got ready for bed, and wondered,
    ‘should i just buy cards instead?’ mama and daddy had just hit the
    hay, so i told them good night, and went on my way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Help me translate following block of the Haskell code. The run function produces text
Following code produces a nested array as a result for keys containing three items:
The following code produces no suitable constructor found error. I am unable to figure
The following code produces wrong and inconsistent output with gcc (4.1.2 20080704) but correct
The following code produces a ListView with the names of the customers: private void
The following code produces the result I don't understand this. Any ideas why? If
Can anyone tell me why the following code produces the alert box that I
I have the following code that produces a background image in a table cell.
Given the following code: var a = 'somegarbage=http://somesite.com/foo/bar/&moregarbage'; var result = a.match(/http.+\//g); Produces the
I use the following code to retrieve image from the phone or SDCard and

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.