Help with encryption and decryption

My teacher gave us a skeleton code to help us start the process of encryption and decryption. We have to use a void encryptDecrypt function and string encrypt and string decrypt as helper functions. I just need guidance as how to start.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  
string results = " ";

	for ( int i = 0; i < input.length(); i++ ) 
	{
		
		if ( input [i] == 'a' )
		{
			
			results = results + "z";
		}
		
		if ( input [i] == 'b' )
		{
			results = results + "y"
		}
		
		if ( input [i] == 'c' )
		{
			results = results + "x";
		}
		if ( input [i] == 'd' )
		{
			results = results + "w";
		}
		if ( input[i] == 'e' )
		{
			results = results + "v";
		}
		if ( input == 'f' );
		{
			results = results + "u";
		}
		if ( input [i] == 'g' )
		{
			results = results + "t";
		}			
		if (input[i] == 'h' )
		{
			results = results + "s";
		}
		if ( input [i] == 'i')
			results = results + "r";
		if ( input[i] == 'j' )
		{
			results = results + 'q';
		}
		if ( input [i] == 'k' )
		{
			results = results + "p";
		}
		if (input[i] == 'l' )
		{
			results = results + "o";
		}
		if (input[i] == 'm' )
		{
			results = results + "n";
		}
		if (input[i] == 'n' )
		{
			results = results + "m";

		}
		if (input[i] == 'o' )
		{
			results = results + "l";
			
		}
		if ( input[i] == 'p' )
		{
			results = results + "k";
		}
		if ( input[i] == 'q' )
		{	
			results = results + "j";
		}
		if ( input[i] == 'r' )
		{
			results = results + "i";
		}
		if ( input[i] == 's' )
		{
			results = results + "h";
		}
		if ( input[i] == 't' )
		{
			results = results + "g";
		}
		if ( input[i] == 'u' )
		{
			results = results + "f";
		}
		if ( input[i] == 'v' )
		{
			results = results + "e";
		}
		if (input[i] == 'w' )
		{
			results = results + "d";
		}
		if ( input[i] == 'x' )
		{
			results = results + "c";
		}
		if ( input[i] == 'y' )
		{
			results = results + "b";
		}
		if ( input[i] == 'z' )
		{
			results = results + "a";
		}
	
	}
One important thing to note is that, in every case, if a encrypts to b, b encrypts to a. This means that you can use that algorithm to do both the encryption and decryption.
so then why would I need a string encrypt and string decrypt as helper functions?
Topic archived. No new replies allowed.