decrypter special character problem

Hi there!
me here again...
I have been trying to make encrypter that just goes forward on alphabets.
but at certain point alphabets run out and the program starts using some special charecters, for me thats ok. but for my decrypter its not.
the decrypter looks at them and just skippes them over when i try to minus the number that i went forward on alphabets.
So my question is:
Is there way to make my decrypter reconise these marks and minus the number that i went forward?
Heres some code:


first the main.cpp
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
#include "decoder.h" // my special header file
string decrypter(string, int * x); // decrypter function

int main()
{
    int a =0;
    int * rand;
    rand = &a;
    string crypt;
    string crypt1;
    string pass;
    cout << endl;
    cout << endl;
    ifstream inFile ("C:\\Users\\Lumivalko\\Desktop\\codeblock                     projects\\f\\merch.txt", ios::in); 

/* opens the .txt file that contains the
crypted password for the decrypter and the message*/

    if(!inFile)
    {
    cout << "Please read the notes.txt file that which should have come with this program!"<< endl;
    Sleep(5000);
    exit(1);
    }
    inFile >> crypt; // constains now crypted pass
    inFile >> crypt1; // crypted message
    inFile.close();
    cout << crypt;
    crypt =decrypter(crypt,rand); 

/* calls the decrypter function and passes
    crypted password and pointer to int a */

    cout << crypt;

    cout << "message found please enter password: " ;
    cin >> pass;
    if(crypt == pass)
    {
     cout << "correct password, starting to decode message" <<endl;
    }
    return 0;
}


string decrypter(string old, int * x) 
{
	string crypted;
	crypted.resize(old.length());

	for(int i = 0; i < old.length(); ++i)
	{
            if(old[i] >64 && old[i] < 123)
			crypted[i] = old[i]- decoder(x); 
	}

	for(int i = 0; i < old.length(); ++i)
	{
            if(old[i] >64 && old[i] < 123)
			crypted[i] = old[i]- decoder(x);
/* decoder is locadet at decoder.cpp*/ 
	}

	return crypted;
}


and now the header file

1
2
3
4
5
6
7
#include <iostream>
#include <fstream>
#include <cstdlib>
#include "windows.h"
using namespace std;
int decoder(int * x);


and now the another .cpp file

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
#include "decoder.h"
int decoder(int * x)
{
    int d;
    int i = 0;
    int b = *x;
    while(i < 1)
    {
        if(b > 20)
        {
            b = 0;
        }
     switch(b)
     {
      case 0:
      d = 3+9-12+2;
      break;
      case 1:
      d = 8+8/2;
      break;
      case 2:
      d = 5+5-4+6/2;
      break;
      case 3:
      d = 2+2+6/2;
      break;
      case 4:
      d = 6+4+6+2/2;
      break;
      case 5:
      d = 2+70-60-4/2;
      break;
      case 6:
      d = 3+6/3;
      break;
      case 7:
      d = 5+5-10+3+7/10;
      break;
      case 8:
      d = 7+4+3/2;
      break;
      case 9:
      d = 15+25+40+20/10;
      break;
      case 10:
      d = 5+3+2+3;
      break;
      case 11:
      d = 9+4+7-1;
      break;
      case 12:
      d =5+100+15+10+20/10;
      break;
      case 13:
      d = 12+12+10/2;
      break;
      case 14:
      d = 5+5+30/2;
      break;
      case 15:
      d = 8+8-4-1;
      break;
      case 16:
      d = 9+4+7+10-12;
      break;
      case 17:
      d = 28-7-7;
      break;
      case 18:
      d = 6+12-6;
      break;
      case 19:
      d = 32+64-32-32/2;
      break;
     }
       b++;
       i++;
    }
 *x = b;
return b;
}



So theres the long code
incase you forgot what I wanted to know:
is there way to make the program recognise special charecters or do i need to go
and change the encrypter code and prevent it that way going into special
charecters?
thanks in advance!
Unless this is homework, I really advice you to use Microsoft Crypto API instead that came with windows.
Topic archived. No new replies allowed.