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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:49:43+00:00 2026-06-02T09:49:43+00:00

So more or less I’m attempting to write a simple encryption/decryption program in C++.

  • 0

So more or less I’m attempting to write a simple encryption/decryption program in C++. Right now i have most of the other basic functions wrote. Although, I’m unsure how to integrate arrays into exactly what I want it to do.

This is my first program in c++ so bear with me.

Basically, i want the user to enter a set of characters a through z and A through Z
I want to use an array to assign each letter a value, IE referenceArray[] = {‘a’, ‘b’, ‘c’, … ‘A’, ‘B’, ‘C’}
Where each of these characters hold the value of their position in the array a = 0, b = 1, etc.
So when the user enters phrase, entArray[], it echoes the phrase back for verification, then using the formula 51 – (theValueOf_enteredArray[0]) where 51 is max value being the theValueOf_entArray[0] being based on the values assigned in referenceArray[] and then I want it to loop and repeat this action for the next character in enteredArray.

So essentially just to clarify exactly what i want the output to be,
if a = 0 and Z = 51

and user entered:
abcdeA
the output would be:
ZYXWVz

if anybody can help, i can send you what i have right now, but like i said it’s all the other portions of the program that i’m required to have, this is the last part and it’s really got me stumped, really just the syntax of the math involved

  • 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-02T09:49:47+00:00Added an answer on June 2, 2026 at 9:49 am

    You can loop over the entry array and once know the index of the current letter, apply the transformation to it:

    for (int i=0; i<SIZE && entArray[i] != '\0'; ++i) {
      char letter = entArray[i];
      char transformedChar = letter;
      int entIdx = getIndex(letter);
      if (entIdx >= 0) {
        int transformedIdx = 51 - entIdx;
        transformedChar = referenceArray[transformedIdx];
      }
      cout << transformedChar;
    }
    

    where SIZE is the size of entArray. You might want to use a named constant for 51 as well.

    Here we first assume that the current letter cannot be transformed (entIdx < 0), if this assumption is false, apply the transformation and get the letter at the transformed location

    To get the index of a letter in the reference array:

    int getIndex(char letter) {
      for (int i=0; i < 51; ++i) {
        if (referenceArray[i] == letter) {
          return i;
        }
      }
      // could not find the letter (e.g. space):
      return -1;
    }
    

    Note: you might want to create and populate a map from letter to index as well to make the lookup easier — you could use a map<char, int>, for instance

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

Sidebar

Related Questions

Why would some paths have significantly more / less weights than other equal length
I know that being open source does not necessarily makes a program more/less secure
The title more or less says it all: I have a function which takes
I have more or less been able to understand and implement all these concepts
I have some more or less linear data of the form: x = [0.1,
I have a more or less large Perl script of ~ 1000 lines. The
Title more or less says it all. In response to a touchesBegan event, my
Is there more elegant (less code) way of find a matrix OUT, with colSums(OUT)<=a
There are more or less straightforward ways to emit or listen signals of existing
Here is (more or less) a related question: Delphi - Populate an imagelist with

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.