Encryption program

closed account (1wvX92yv)
Hello forum people....

I am trying to make an encryption program with various kinds of encryption techniques..... Presently I have just the matrix based encryption program. - what it basically does is to input the given string of characters row wise into a matrix after removing all the spaces and read the characters column wise to get a code.... Each code is tagged with two numbers which act as row and column numbers to decrypt it again.... It's working pretty fine but now I am out of ideas....

I considered the idea of using ascii codes for letters but any other innovative idea is highly welcome.....

Give me some ideas people.....

You could do something simple like moving the chars up one or more places then decrease for decrypt like
for(int i = 0; i <string.size(); i++) str[i]++;
closed account (1wvX92yv)
i know.............but there are many of those kinds of programs ..........i want something nice...................
you can manually choose each character by using character map copy past and a switch statement or something then
closed account (1wvX92yv)
hmm......i will give it a try...........

Here you go.
http://en.wikipedia.org/wiki/Advanced_Encryption_Standard

i know.............but there are many of those kinds of programs ..........i want something nice...................

I have an idea for a relatively strong encryption program.

It mimics the one-time pad technique.

1) you check the size of the input file
2) you generate the "key file" (that's how I call it), which is filled with random data, of exactly the same size as the input file
3) you "blend" the input and key files together by using the XOR operation (which is operator^ in C/C++)
4) to decrypt simply "blend" the output file with the original key file

http://en.wikipedia.org/wiki/XOR_cipher

The drawbacks are:

1) you will now have two files to save: the output file and the key file... so if you encrypt 600 MB, you'll end up with 1200 MB

2) the cipher can be broken if the key file does not have true random content after it's generated -- although this shouldn't really be an issue unless you try to hide things from the CIA (and you can try to mitigate this problem by using C++11's random library, if your compiler provides it)

http://cplusplus.com/reference/random/
Last edited on
Or you could try something like this:
I made it for fun because it seemed like something interesting to do
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include <iostream>

std::string encrypt(std::string, std::string);
std::string decrypt(std::string, std::string);
std::string input();
void output(std::string, std::string, std::string);
void welcome();

int main()
{
    welcome();

    std::string strToEncrypt;
    strToEncrypt = input();
    std::cout << "Please enter an encryption number.\n> " << std::flush;
    std::string encryptionNumber;
    encryptionNumber = input();
    std::string encryptedStr;
    encryptedStr = encrypt(strToEncrypt, encryptionNumber);
    std::cout << "Please enter a decryption number.\n> " << std::flush;
    std::string decryptionNumber;
    decryptionNumber = input();
    std::string decryptedStr;
    decryptedStr = decrypt(encryptedStr, decryptionNumber);
    output(strToEncrypt, encryptedStr, decryptedStr);

}

void welcome()
{
    std::cout << "Welcome to my encryption and decryption program!\nPlease enter a string to be encrypted.\n> " << std::flush;
}

std::string input()
{
    std::string str;
    std::getline(std::cin, str);
    return(str);
}

std::string encrypt(std::string a, std::string b)
{
    for(unsigned int i = 0; i < b.size(); i++)
    {
        switch(b[i])
        {
        case '1': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i]++;
            }
            break;
        case '2': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] -= 2;
            }
            break;
        case '3': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] += 3;
            }
            break;
        case '4': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] -= 4;
            }
            break;
        case '5': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] += 5;
            }
            break;
        case '6': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] -= 6;
            }
            break;
        case '7': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] += 7;
            }
            break;
        case '8': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] -= 8;
            }
            break;
        case '9': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] += 9;
            }
            break;
        case '0': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] -= 10;
            }
            break;
        }
    }
    return(a);
}

std::string decrypt(std::string a, std::string b)
{
    for(unsigned int i = 0; i < b.size(); i++)
    {
        switch(b[i])
        {
        case '1': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i]--;
            }
            break;
        case '2': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] += 2;
            }
            break;
        case '3': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] -= 3;
            }
            break;
        case '4': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] += 4;
            }
            break;
        case '5': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] -= 5;
            }
            break;
        case '6': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] += 6;
            }
            break;
        case '7': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] -= 7;
            }
            break;
        case '8': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] += 8;
            }
            break;
        case '9': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] -= 9;
            }
            break;
        case '0': for(unsigned int i = 0; i < a.size(); i++)
            {
                a[i] += 10;
            }
            break;
        }
    }
    return(a);
}

void output(std::string a, std::string b, std::string c)
{
    std::cout << "Before encryption: " << a << std::endl;
    std::cout << "After encryption: " << b << std::endl;
    std::cout << "After decryption: " << c << std::endl;
}
closed account (1wvX92yv)
now thats what i call an encryption program......:):):)

thanks a lot mate, maybe i can use these ideas to complete my final year project...........


really appreciate the help......

P.S. i liked your program too.......:)
Topic archived. No new replies allowed.