I am trying my first encryption program and I want to convert the letters to numbers then do an equation to change the numbers. Then when the encryption is done it should be a bunch of random numbers then the decryption should come back to normal (what the user input in the first place). Heres what I have so far, any help will be greatly appreciated (the code is very sloppy).

#include <iostream>
using namespace std;

int main () {
	char letters;
	char a ='a';
	char b ='b';
	char c ='c';
	char d ='d';
	char e ='e';
	char f ='f';
	char g ='g';
	char h ='h';
	char i ='i';
	char j ='j';
	char k ='k';
	char l ='l';
	char m ='m';
	char n ='n';
	char o ='o';
	char p ='p';
	char q ='q';
	char r ='r';
	char s ='s';
	char t ='t';
	char u ='u';
	char v ='v';
	char w ='w';
	char x ='x';
	char y ='y';
	char z ='z';
	
	cout<<"Please enter the words you want to encrypt: ";
	cin>>letters;
	
	letters = (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z);
	a = '1';
	b = '2';
	c = '3';
	d = '4';
	e = '5';
	f = '6';
	g = '7';
	h = '8';
	i = '9';
	j = '10';
	k = '11';
	l = '12';
	m = '13';
	n = '14';
	o = '15';
	p = '16';
	q = '17';
	r = '18';
	s = '19'; 
	t = '20'; 
	u = '21';
	v = '22'; 
	w = '23';
	x = '24';
	y = '25';
	z = '26';
	
	letters = letters * letters / letters + letters;
	
	cout<<" The encrypted content is "<<letters<<endl;
	}

I think you should use a loop and array to store the letters and numbers. That is a very laborious job there.

You should scrap this code completely.

You need to look into the values of characters. For example, the letter 'A' is the same as the integer value 65.

Run this program and see the correlation between characters and numbers. Then think about your idea with this information in mind.

#include <iostream>
using namespace std;

int main()
{    
    int i;
    
    for (i=32; i<126; i++) 
    {
        cout << (char) i << "  " << (int) i << endl;
    }
    
    return 1;
}
#include <iostream>
using namespace std;

int main()
{    
    int i;
    
    for (i=32; i<126; i++) 
    {
        cout << [B](char)[/B] i << "  " << [B](int)[/B] i << endl;
    }
    
    return 1;
}

What I don't get it, is what is the brackets does...? Are you trying to change the output value of i so the value of i is straightly changed to the encrypted value?

What I don't get it, is what is the brackets does...? Are you trying to change the output value of i so the value of i is straightly changed to the encrypted value?

Why are u over writing letters after cin

Why are u over writing letters after cin

I don't quite understand what are you trying to say....Could you make it a lil' bit more detail?

Wow thanks so much you fixed all my problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.