Wencrypt(char* file)
{
char plaintext[1024], ciphertext[1024], password[1024];
ifstream fin(file);
fin.close();
int strlngth = strlen(plaintext);
ttyping(" What will the password be?", 25, GRAY, YELLOW, WHITE, 7);
cin>>password;
for(int i = 1, opener = 0; i <= password[opener]; i++, opener++)
{
ciphertext[i] = password[opener];
}
ciphertext[0] = opener;
for(i = i; i < strlngth; i++)
{
ciphertext[i] = plaintext[i] + 111;
};
ofstream fout(file);
fout << ciphertext;
return 0;
}
Wdecrypt(char* file)
{
char plaintext[1024], ciphertext[1024], password[1024], vpassword[1024];
int opener;
ifstream fin(file);
fin.close();
opener = ciphertext[0];
int strlngth = strlen(ciphertext);
for(int i = 1, k = 0; i <= opener; i++, k++)
{
vpassword[k] = ciphertext[i];
}
for(i = i; i < strlngth; i++)
{
ciphertext[i] = plaintext[i] - 111;
};
ciphertext[i + 1] = ' ';
ciphertext[i + 2] = ' ';
ciphertext[i + 3] = ' ';
ciphertext[i + 4] = ' ';
ciphertext[i + 5] = ' ';
ciphertext[i + 6] = ' ';
ofstream fout(file);
fout << ciphertext;
return 0;
}
these are my main functions for encrypting and decrypting. Some functions included in these functions you wont recognize, such as ttyping (because they are homemade), but I am having problems with this code. this is what im attempting to do:
1. Ask for a Password to secure the file with
2.Get the number of characters in the password.
3.Put the number in the first char of the file
4.Use the number to count how many letters are in the password when it is decrypted.
5.decrypt the password
6.verify the password
7.if its correct, decrypt the file
Any help on my coding would be greatly appreciated. Thx in advance