Authentication

Hello, this is my first post so please bare with me. I'm currently working on an assignment, but have ran into a little bit of trouble. Below is the part I'm struggling on, I have no idea where to start and was wondering if anyone could give me some insight and a possible solution which will help me figure out the problem, thanks!

Authentication:
To use the lift the user enters their name which is encoded (encrypted) and compared
against a list of authorized ciphers. If the name is accepted the user may proceed to call
the lift, if not the user has 2 further attempts after which the lift is locked and
unavailable for use and the program exits. Your program should accommodate 4
named users, ‘hardcoded’ into the program, and you should make clear the names of
these users in your report and in a comment in the code. The encryption / encoding
algorithm is provided below:
The name is to be encoded by shifting the letters of the alphabet by 11 places, so
„a‟ becomes „l‟, „b‟ becomes „m‟ etc. So the name “Joe Bloggs” would be
encoded as “Uzp Mwzrrd”. Encoding should „wrap-around‟ so that the letter
after „z‟ is „a‟ and therefore „z‟ encodes to „k‟. This applies to both uppercase
and lowercase.


 
  No code yet.
I would suggest you to make the std::string encode(std::string) function that would encode the user input
Would it be possible for you to give me an example?

Thanks!
Sure, this is the identity encoding
1
2
3
4
5
6
7
8
9
10
11
12
#include <string>
#include <iostream>

std::string encode(std::string s){
   return s;
}

int main(){
   std::string input;
   while( std::getline(std::cin,input) )
      std::cout << encode(input) << '\n';
}
Topic archived. No new replies allowed.