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 8426317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:30:45+00:00 2026-06-10T04:30:45+00:00

I’m working on a Shit Cipher and decrypting a particular piece of text. Ok,

  • 0

I’m working on a Shit Cipher and decrypting a particular piece of text. Ok, so, how the program works:

  1. Takes the characters from a text file
  2. Shift each of the characters 9 places down the alphabet.

Now, I have done this, however, I know that the character cannot be shift always by 9 places, so the program looks at where the character is in the alphabet char array and then if it can be done, it just adds 9, and if it cannot be done, it just takes 9 away (Finds the difference). But, it’s not working and I can’t figure out where I am going wrong.

Here is the code:

#include <iostream>
#include <fstream> 
using namespace std;

string inputFile = "";
#define MAX_FILE_SIZE 10000
const char alphabet[26] =   {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
const char alphabetUpper[26] =   
{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

const int sizeAlpha = sizeof(alphabet)/sizeof(alphabet[0]);
void Data(char* theData)
{
ifstream txtFile(inputFile.c_str());
if(!txtFile.is_open())
{
    cerr << "Cannot open text file";
}
txtFile.read(theData, 520);
}

int main(int argc, char *argv[]) {

char getData[MAX_FILE_SIZE];

Data(getData);

char decrypted[520];

int algorthm;

for(unsigned i=0; (i < 520); i++)
{
    for(unsigned j=0; (j < 26); j++)
    {
        if(getData[i] == alphabet[j] || alphabetUpper[j])
        {
            algorthm = j + 9; // we move 9 places.

            if(sizeAlpha < algorthm)
            {
                decrypted[i] = alphabet[algorthm];

            }else if(algorthm > sizeAlpha || algorthm == sizeAlpha) 
            {
                algorthm = sizeAlpha - j;

                decrypted[i] = alphabet[algorthm];
            }
        }
    }
}

for(unsigned i=0; (i < 520); i++)
{
    cout << decrypted[i]; 
}
}

Anyone know where I’m going wrong, or, can offer a simular solution?

  • 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-10T04:30:47+00:00Added an answer on June 10, 2026 at 4:30 am

    if it can be done, it just adds 9, and if it cannot be done, it just takes 9 away

    That cannot possibly be reversible, because you map two different values to the same one.

    Instead, you have to wrap around:

    unsigned char shiftChar(unsigned char const plain, signed char const by) {
      unsigned char const caseBit = plain & ('a' ^ 'A');
      unsigned char offset = (plain ^ caseBit) - ('a' & 'A');
      offset += ('z' - 'a' + 1) + by; // there's your "shift"
      offset %= ('z' - 'a' + 1);
      return caseBit | (offset + ('a' & 'A'));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a reasonable size flat file database of text documents mostly saved in
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.