Encryption

I have also found an encryption algoritm
in this page but I have a problem with it
I cant save the encrypted string in a file
The program is this i have modified it a little bit

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
char string[] = "klausveliu";
int x = 0, l = strlen(string);

printf("ORIGINAL (%d BYTES) : %s\n\n", l, string);
if (l < 10){
cout<<"\nPass not very secure!\n";
}
// Encrypt
for (x = 0; x < l; x ++)
string[x] += (256^x) * (x % 256);

printf("\"ENCRYPTED\": %s\n\n", string);

// Decrypt
for (x = 0; x < l; x ++)
string[x] -= (256^x) * (x % 256);

cout<<"Decrypted :"<<string<<endl;
system("pause");
return 0;
}


If someone know how to do this please help
even if you have an another way to do this.
there should be no problem with saving the string into a file, just make sure your file is opened in binary and than write it... also, you might get strange results when printing the encripted string to the console
i've got one thing to say, i know you said you found it but :
it tells you that L < 10 is not very secure, and yet the encryption algorithm is not very secure at all. (256^x) * (x % 256) ... yeah...
maybe you should replace it with a simple RSA algorithm. use a prime number generator to get some high primes for it, then the encrypted password will be using "INDUSTRY-GRADE ENCRYPTION!" unless you put at the top of the source file (if its included) :

1
2
3
4
/* Note To Self : The Private Key Is ... (-numbers-, -numbers-)...
Post-Note To Self : Delete This From The Source Before Distribution.
Post-Post-Note To Self : Copy The Private Key Out First
Post-Post-Post-Note To Self : Monkeys! */


btw, use code when you post a code, it'll put that around it. looks better.
Topic archived. No new replies allowed.